Changeset 1338050
- Timestamp:
- 01/28/2016 12:53:05 PM (10 years ago)
- Location:
- perfectdashboard/trunk
- Files:
-
- 3 edited
-
class/perfectdashboard-api-class.php (modified) (10 diffs)
-
perfectdashboard.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
perfectdashboard/trunk/class/perfectdashboard-api-class.php
r1329197 r1338050 1 1 <?php 2 2 /** 3 * @version 1.2. 03 * @version 1.2.1 4 4 * @package Perfect Dashboard 5 * @copyright © 201 5Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co5 * @copyright © 2016 Perfect Web sp. z o.o., All rights reserved. http://www.perfect-web.co 6 6 * @license GNU/GPL http://www.gnu.org/licenses/gpl-3.0.html 7 7 * @author Perfect-Web … … 326 326 ); 327 327 } 328 echo json_encode($this->output);328 echo '###' . json_encode($this->output) . '###'; 329 329 die(); 330 330 } … … 729 729 private function installBackupTool() 730 730 { 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; 746 739 747 740 if (empty($download_url) || empty($install_dir) || empty($login) || empty($password) || empty($secret)) { … … 754 747 755 748 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 } 760 766 } 761 767 … … 765 771 if (!empty($params['ak_prefix_folder']) && 766 772 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 } 771 791 } 772 792 … … 780 800 if (is_wp_error($download_file)) { 781 801 $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_'; 785 806 786 807 $akeeba_path = ABSPATH . $install_dir . '/'; … … 790 811 mkdir($akeeba_path); 791 812 } 792 813 793 814 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); 803 818 804 819 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 } 806 825 } else { 807 826 $this->output = array('state' => 0, 'message' => 'package_extract_error'); 808 827 return false; 809 828 } 829 } else { 830 $this->output = array('state' => 0, 'message' => 'package_or_install_folder_doesnt_exist'); 831 return false; 810 832 } 811 833 … … 814 836 } 815 837 816 $this->output = array('state' => 1, 'message' => 'installed');838 $this->output = array('state' => 1, 'message' => $update ? 'updated' : 'installed'); 817 839 } 818 840 819 841 public function configureBackupTool() 820 842 { 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; 825 844 826 845 $install_dir = $this->getBackupToolPath(true); … … 945 964 } 946 965 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) 948 967 { 949 968 if (empty($src)) { … … 954 973 $dest_path = ABSPATH . $dest . '/'; 955 974 956 if ( @rename($src_path, $dest_path) === true)975 if ($src_path == $dest_path OR @rename($src_path, $dest_path) === true) 957 976 { 958 $this->initAkeeba($dest, $login, $password, $secret, $prefix_db );977 $this->initAkeeba($dest, $login, $password, $secret, $prefix_db, $htaccess); 959 978 $this->output = array('state' => 1, 'message' => 'installed'); 960 979 return true; -
perfectdashboard/trunk/perfectdashboard.php
r1329197 r1338050 4 4 * Plugin URI: https://perfectdashboard.co 5 5 * Description: 6 * Version: 1.2. 06 * Version: 1.2.1 7 7 * Text Domain: perfectdashboard 8 8 * Author: Perfect-Web -
perfectdashboard/trunk/readme.txt
r1329199 r1338050 5 5 Requires at least: 3.5.0 6 6 Tested up to: 4.4.1 7 Stable tag: 1.2. 07 Stable tag: 1.2.1 8 8 License: GNU/GPL 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 86 86 == Changelog == 87 87 88 = 1.2.1 / 28-01-2016 89 90 * update backup tool 91 88 92 = 1.2.0 / 15-01-2016 89 93
Note: See TracChangeset
for help on using the changeset viewer.