Plugin Directory

Changeset 3238447


Ignore:
Timestamp:
02/11/2025 09:27:00 AM (13 months ago)
Author:
robomaintainercom
Message:

1.1.0

Location:
robomaintainer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • robomaintainer/trunk/acua-robomaintainer.php

    r3190930 r3238447  
    33Plugin Name: RoboMaintainer
    44Description: Automatic updates without breaking anything.
    5 Version: 1.0.0
     5Version: 1.1.0
    66Author: acua technology gmbh
    77License: GPLv2 or later
     
    175175            }
    176176
     177            if ( isset( $_POST['RM_ACTION'] ) && $_POST['RM_ACTION'] === 'RM_ADDITIONAL_EMAILS' ) {
     178                if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'RM_ADDITIONAL_EMAILS' ) ) {
     179                    wp_die( 'Security check failed' );
     180                }
     181                $update_data = $rmClass->setPreferences([
     182                    'RM_ACTION' => sanitize_text_field('RM_ADDITIONAL_EMAILS'),
     183                    'additional_emails' => array_map('sanitize_text_field', wp_unslash($_POST['additional_emails'])),
     184                ]);
     185            }
     186
    177187            include 'parts/timezones.php';
    178188            $isSiteRegistered = $rmClass->isSiteRegistered();
     
    242252    $folder_name        = sanitize_text_field( wp_unslash( $_GET['folderName'] ?? '' ) );
    243253    $backup_folder_name = sanitize_text_field( wp_unslash( $_GET['backupFolderName'] ?? null ) );
     254    $backup_folder_created = true;
    244255
    245256    if (!$plugin_slug) {
     
    250261
    251262    // Define paths
    252     $plugin_dir = ABSPATH . 'wp-content/plugins/' . $folder_name . '/';
    253     $backup_dir  = ABSPATH . 'wp-content/plugins-rm/' . $backup_folder_name . '/';
     263    $plugin_dir = '../../../wp-content/plugins/' . $folder_name . '/';
     264    $backup_dir = '../../../wp-content/plugins-rm/' . $backup_folder_name . '/';
    254265
    255266    // Create backup
     
    257268        global $wp_filesystem;
    258269        if (!$wp_filesystem->mkdir($backup_dir, 0755)) {
    259             exit("Failed to create backup directory.");
     270            $backup_folder_created = false;
     271            // exit("Failed to create backup directory.");
    260272        }
    261273    }
    262274
    263275    // Copy all plugins to the backup directory
    264     $backup_success = true;
    265     $dir_iterator = new RecursiveDirectoryIterator($plugin_dir, RecursiveDirectoryIterator::SKIP_DOTS);
    266     $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
    267     foreach ($iterator as $file) {
    268         $dest = $backup_dir . $iterator->getSubPathName();
    269         if ($file->isDir()) {
    270             global $wp_filesystem;
    271             if (!$wp_filesystem->mkdir($dest, 0755) && !is_dir($dest)) {
    272                 $backup_success = false;
    273                 break;
    274             }
    275         } else {
    276             if (!$wp_filesystem->copy($file, $dest)) {
    277                 $backup_success = false;
    278                 break;
    279             }
    280         }
    281     }
    282 
    283     if (!$backup_success) {
    284         exit("Failed to back up the plugins directory.");
    285     }
     276    if($backup_folder_created) {
     277        $backup_success = true;
     278        $dir_iterator = new RecursiveDirectoryIterator($plugin_dir, RecursiveDirectoryIterator::SKIP_DOTS);
     279        $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
     280        foreach ($iterator as $file) {
     281            $dest = $backup_dir . $iterator->getSubPathName();
     282            if ($file->isDir()) {
     283                global $wp_filesystem;
     284                if (!$wp_filesystem->mkdir($dest, 0755) && !is_dir($dest)) {
     285                    $backup_success = false;
     286                    break;
     287                }
     288            } else {
     289                if (!$wp_filesystem->copy($file, $dest)) {
     290                    $backup_success = false;
     291                    break;
     292                }
     293            }
     294        }
     295    } else {
     296        $backup_success = false;
     297    }
     298
     299    // if (!$backup_success) {
     300    //     exit("Failed to back up the plugins directory.");
     301    // }
    286302
    287303    include_once ABSPATH . 'wp-admin/includes/plugin.php';
     
    340356
    341357    // Define paths
    342     $backup_dir = realpath(ABSPATH . 'wp-content/plugins-rm/' . $backup_folder_name);
    343     $plugin_dir = realpath(ABSPATH . 'wp-content/plugins/' . $folder_name);
     358    $backup_dir = realpath('../../../wp-content/plugins-rm/' . $backup_folder_name);
     359    $plugin_dir = realpath('../../../wp-content/plugins/' . $folder_name);
    344360
    345361    // Validate paths
    346     if (!$backup_dir || !is_dir($backup_dir) || strpos($backup_dir, realpath(ABSPATH . 'wp-content/plugins-rm/')) !== 0) {
     362    if (!$backup_dir || !is_dir($backup_dir) || strpos($backup_dir, realpath('../../../wp-content/plugins-rm/')) !== 0) {
    347363        echo wp_json_encode(array('status' => false, 'message' => "Invalid or non-existent backup folder"));
    348364        exit();
    349365    }
    350366
    351     if (!$plugin_dir || !is_dir($plugin_dir) || strpos($plugin_dir, realpath(ABSPATH . 'wp-content/plugins/')) !== 0) {
     367    if (!$plugin_dir || !is_dir($plugin_dir) || strpos($plugin_dir, realpath('../../../wp-content/plugins/')) !== 0) {
    352368        echo wp_json_encode(array('status' => false, 'message' => "Invalid or non-existent plugin folder"));
    353369        exit();
     
    395411
    396412    $backup_folder_name = sanitize_text_field( wp_unslash( $_GET['backupFolderName'] ?? null ) );
    397     $backup_dir  = ABSPATH . 'wp-content/plugins-rm/' . $backup_folder_name . '/';
     413    $backup_dir  = '../../../wp-content/plugins-rm/' . $backup_folder_name . '/';
    398414
    399415    // Validate and sanitize folder name
  • robomaintainer/trunk/classes/AcuaRmWordpressClass.php

    r3190930 r3238447  
    7272                'post_status'    => 'publish',
    7373                'posts_per_page' => -1,
     74                'orderby'        => 'date',
     75                'order'          => 'ASC',
    7476            );
    75 
     77       
    7678            $query = new WP_Query($args);
    77 
     79       
    7880            if ($query->have_posts()) :
    7981                while ($query->have_posts()) : $query->the_post();
     
    8385                wp_reset_postdata();
    8486            endif;
    85         }
     87        }       
    8688
    8789        header('Content-Type: application/json; charset=utf-8');
  • robomaintainer/trunk/pages/settings.php

    r3190930 r3238447  
    1111            <button name="RM_ACTION" class="button button-primary action" value="ACUA_REGISTER">Request</button>
    1212            <p>&#10060; Please enter your e-mail address and you will receive your API key and temporary password.</p>
     13            <p>&#10060; Already have an account and API key? Enter your email address again to add this page to your account.</p>
    1314        </form>
    1415    <?php endif; ?>
     
    3334
    3435<?php if ($is_valid && $isSiteRegistered && $instanceData) { ?>
     36
     37    <?php
     38        $additional_emails = [];
     39        if($instanceData && $instanceData->site && $instanceData->site->additional_emails) {
     40            $parts = explode(';', $instanceData->site->additional_emails);
     41            if(is_array($parts)) {
     42                $additional_emails = $parts;
     43            }
     44        }
     45    ?>
     46
     47    <form method="POST">
     48        <div class="card">
     49            <h2 class="title">Additional emails for notifiations</h2>
     50            <?php
     51                foreach([0, 1, 2] as $i) { ?>
     52                <p>
     53                    <input name="additional_emails[]" size="60" type="email" value="<?php
     54                    echo isset($additional_emails[$i]) && filter_var($additional_emails[$i], FILTER_VALIDATE_EMAIL) ? esc_attr($additional_emails[$i]) : esc_attr('');
     55                    ?>" autocomplete="off" placeholder="Additional email"/>
     56                </p>
     57            <?php } ?>
     58            <?php wp_nonce_field( 'RM_ADDITIONAL_EMAILS' ); ?>
     59            <button name="RM_ACTION" class="button button-primary action" value="RM_ADDITIONAL_EMAILS">Save</button>
     60        </div>
     61    </form>
     62
    3563    <div class="card">
    3664        <h2 class="title">Plan details</h2>
Note: See TracChangeset for help on using the changeset viewer.