Plugin Directory

Changeset 1338050


Ignore:
Timestamp:
01/28/2016 12:53:05 PM (10 years ago)
Author:
piotrmocko
Message:

Version 1.2.1

Location:
perfectdashboard/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • perfectdashboard/trunk/class/perfectdashboard-api-class.php

    r1329197 r1338050  
    11<?php
    22/**
    3  * @version 1.2.0
     3 * @version 1.2.1
    44 * @package Perfect Dashboard
    5  * @copyright © 2015 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co
     5 * @copyright © 2016 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co
    66 * @license GNU/GPL http://www.gnu.org/licenses/gpl-3.0.html
    77 * @author Perfect-Web
     
    326326            );
    327327        }
    328         echo json_encode($this->output);
     328        echo '###' . json_encode($this->output) . '###';
    329329        die();
    330330    }
     
    729729    private function installBackupTool()
    730730    {
    731         if (isset($_POST['download_url'])) {
    732             $download_url = $this->filter->clean($_POST['download_url'], 'ba'.'se'.'64');
    733         }
    734         if (isset($_POST['install_dir'])) {
    735             $install_dir = $this->filter->clean($_POST['install_dir'], 'cmd');
    736         }
    737         if (isset($_POST['login'])) {
    738             $login = $this->filter->clean($_POST['login'], 'alnum');
    739         }
    740         if (isset($_POST['password'])) {
    741             $password = $this->filter->clean($_POST['password'], 'alnum');
    742         }
    743         if (isset($_POST['secret'])) {
    744             $secret = $this->filter->clean($_POST['secret'], 'alnum');
    745         }
     731        $download_url = isset($_POST['download_url']) ? $this->filter->clean($_POST['download_url'], 'ba'.'se'.'64') : null;
     732        $install_dir  = isset($_POST['install_dir']) ? $this->filter->clean($_POST['install_dir'], 'cmd') : null;
     733        $login        = isset($_POST['login']) ? $this->filter->clean($_POST['login'], 'alnum') : null;
     734        $password     = isset($_POST['password']) ? $this->filter->clean($_POST['password'], 'alnum') : null;
     735        $secret       = isset($_POST['secret']) ? $this->filter->clean($_POST['secret'], 'alnum') : null;
     736        $version      = isset($_POST['version']) ? $this->filter->clean($_POST['version'], 'cmd') : null;
     737        $htaccess     = isset($_POST['htaccess']) ? $this->filter->clean($_POST['htaccess'], 'cmd') : null;
     738        $update       = false;
    746739
    747740        if (empty($download_url) || empty($install_dir) || empty($login) || empty($password) || empty($secret)) {
     
    754747
    755748        if (!empty($backup_dir) && file_exists(ABSPATH.$backup_dir.'/index.php')) {
    756             $prefix_db = $this->getAkeebaDbPrefix($backup_dir);
    757             $this->changeBackupAcces($login, $password, $secret, $prefix_db, $install_dir, $backup_dir);
    758             $this->output = array('state' => 1, 'message' => 'installed');
    759             return true;
     749           
     750            if ($install_dir != $backup_dir) {
     751                $prefix_db = $this->getAkeebaDbPrefix($backup_dir);
     752                $this->changeBackupAcces($login, $password, $secret, $prefix_db, $htaccess, $install_dir, $backup_dir);
     753            }
     754
     755            if (!empty($version) && file_exists(ABSPATH.$backup_dir.'/version.php')) {
     756                include_once ABSPATH.$backup_dir.'/version.php';
     757                if (defined('AKEEBA_VERSION') && version_compare(AKEEBA_VERSION, $version) === -1) {
     758                    $update = true;
     759                }
     760            }
     761
     762            if (!$update) {
     763                $this->output = array('state' => 1, 'message' => 'installed');
     764                return true;
     765            }
    760766        }
    761767
     
    765771        if (!empty($params['ak_prefix_folder']) &&
    766772            file_exists(ABSPATH.$params['ak_prefix_folder'].'perfectdashboard_akeeba'.'/index.php')) {
    767             $prefix_db = $params['ak_prefix_db'];
    768             $this->changeBackupAcces($login, $password, $secret, $prefix_db, $install_dir, $backup_dir);
    769             $this->output = array('state' => 1, 'message' => 'installed');
    770             return true;
     773
     774            $backup_dir = $params['ak_prefix_folder'].'perfectdashboard_akeeba';
     775            if ($install_dir != $backup_dir) {
     776                $prefix_db = $params['ak_prefix_db'];
     777                $this->changeBackupAcces($login, $password, $secret, $prefix_db, $htaccess, $install_dir, $backup_dir);
     778            }
     779
     780            if (!empty($version) && file_exists(ABSPATH.$backup_dir.'/version.php')) {
     781                include_once ABSPATH.$backup_dir.'/version.php';
     782                if (defined('AKEEBA_VERSION') && version_compare(AKEEBA_VERSION, $version) === -1) {
     783                    $update = true;
     784                }
     785            }
     786
     787            if (!$update) {
     788                $this->output = array('state' => 1, 'message' => 'installed');
     789                return true;
     790            }
    771791        }
    772792
     
    780800        if (is_wp_error($download_file)) {
    781801            $this->output = array('success' => 0, 'message' => 'download_error');
    782         }
    783 
    784         $prefix_db     = 'as'.substr(md5(uniqid('akeeba_tables')), 0, 5).'_'.'perfectdashboard_akeeba_';
     802            return false;
     803        }
     804
     805        $prefix_db = 'as'.substr(md5(uniqid('akeeba_tables')), 0, 5).'_'.'perfectdashboard_akeeba_';
    785806
    786807        $akeeba_path = ABSPATH . $install_dir . '/';
     
    790811            mkdir($akeeba_path);
    791812        }
    792 
     813       
    793814        if(file_exists($akeeba_package_path)) {
    794 
    795             $zip = new ZipArchive;
    796             $opened = $zip->open($akeeba_package_path);
    797             $extracted = false;
    798 
    799             if($opened) {
    800                 $extracted = $zip->extractTo($akeeba_path);
    801                 $zip->close();
    802             }
     815           
     816            WP_Filesystem();
     817            $extracted = unzip_file($akeeba_package_path, $akeeba_path);
    803818
    804819            if($extracted) {
    805                 $this->initAkeeba($install_dir, $login, $password, $secret, $prefix_db);
     820                if ($update) {
     821                    $this->initAkeeba($install_dir, null, null, $secret, null, $htaccess);
     822                } else {
     823                    $this->initAkeeba($install_dir, $login, $password, $secret, $prefix_db, $htaccess);
     824                }
    806825            } else {
    807826                $this->output = array('state' => 0, 'message' => 'package_extract_error');
    808827                return false;
    809828            }
     829        } else {
     830            $this->output = array('state' => 0, 'message' => 'package_or_install_folder_doesnt_exist');
     831            return false;
    810832        }
    811833
     
    814836        }
    815837
    816         $this->output = array('state' => 1, 'message' => 'installed');
     838        $this->output = array('state' => 1, 'message' => $update ? 'updated' : 'installed');
    817839    }
    818840
    819841    public function configureBackupTool()
    820842    {
    821         $htaccess_param = null;
    822         if (isset($_POST['htaccess'])) {
    823                 $htaccess_param = $this->filter->clean($_POST['htaccess'], 'string');
    824         }
     843        $htaccess_param = isset($_POST['htaccess']) ? $this->filter->clean($_POST['htaccess'], 'string') : null;
    825844
    826845        $install_dir = $this->getBackupToolPath(true);
     
    945964    }
    946965
    947     protected function changeBackupAcces($login, $password, $secret, $prefix_db, $dest, $src = null)
     966    protected function changeBackupAcces($login, $password, $secret, $prefix_db, $htaccess = null, $dest, $src = null)
    948967    {
    949968        if (empty($src)) {
     
    954973        $dest_path = ABSPATH . $dest . '/';
    955974
    956         if (@rename($src_path, $dest_path) === true)
     975        if ($src_path == $dest_path OR @rename($src_path, $dest_path) === true)
    957976        {
    958             $this->initAkeeba($dest, $login, $password, $secret, $prefix_db);
     977            $this->initAkeeba($dest, $login, $password, $secret, $prefix_db, $htaccess);
    959978            $this->output = array('state' => 1, 'message' => 'installed');
    960979            return true;
  • perfectdashboard/trunk/perfectdashboard.php

    r1329197 r1338050  
    44 * Plugin URI: https://perfectdashboard.co
    55 * Description:
    6  * Version: 1.2.0
     6 * Version: 1.2.1
    77 * Text Domain: perfectdashboard
    88 * Author: Perfect-Web
  • perfectdashboard/trunk/readme.txt

    r1329199 r1338050  
    55Requires at least: 3.5.0
    66Tested up to: 4.4.1
    7 Stable tag: 1.2.0
     7Stable tag: 1.2.1
    88License: GNU/GPL
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    8686== Changelog ==
    8787
     88= 1.2.1 / 28-01-2016
     89
     90* update backup tool
     91
    8892= 1.2.0 / 15-01-2016
    8993
Note: See TracChangeset for help on using the changeset viewer.