Ejemplo n.º 1
0
 /**
  * Save the file to the specified path
  * @return boolean TRUE on success
  */
 function save($path)
 {
     $wpFileSystem = MainWPUtility::getWPFilesystem();
     if ($wpFileSystem != null) {
         $path = str_replace(MainWPUtility::getBaseDir(), '', $path);
         $moved = $wpFileSystem->put_contents($path, file_get_contents($_FILES['qqfile']['tmp_name']));
     } else {
         $moved = move_uploaded_file($_FILES['qqfile']['tmp_name'], $path);
     }
     if (!$moved) {
         return false;
     }
     return true;
 }
 protected static function checkDirectoryMainWPDirectory()
 {
     $dirs = MainWPUtility::getMainWPDir();
     $path = $dirs[0];
     if (!is_dir(dirname($path))) {
         //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', 'Directory not found', false);
         return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Not Found', false);
     }
     $hasWPFileSystem = MainWPUtility::getWPFilesystem();
     global $wp_filesystem;
     if ($hasWPFileSystem && !empty($wp_filesystem)) {
         if (!$wp_filesystem->is_writable($path)) {
             //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', 'Directory not writable', false);
             return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Not Writable', false);
         }
     } else {
         if (!is_writable($path)) {
             //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', 'Directory not writable', false);
             return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Not Writable', false);
         }
     }
     //return self::renderDirectoryRow('MainWP upload directory', $path, 'Writable', '/', true);
     return self::renderDirectoryRow('MainWP Upload Directory', 'Writable', 'Writable', true);
 }
Ejemplo n.º 3
0
 public static function trashExtension()
 {
     ob_start();
     $slug = $_POST['slug'];
     include_once ABSPATH . '/wp-admin/includes/plugin.php';
     $thePlugin = get_plugin_data($slug);
     if ($thePlugin != null && $thePlugin != '') {
         deactivate_plugins($slug);
     }
     if (file_exists(ABSPATH . '/wp-admin/includes/screen.php')) {
         include_once ABSPATH . '/wp-admin/includes/screen.php';
     }
     include_once ABSPATH . '/wp-admin/includes/file.php';
     include_once ABSPATH . '/wp-admin/includes/template.php';
     include_once ABSPATH . '/wp-admin/includes/misc.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
     MainWPUtility::getWPFilesystem();
     global $wp_filesystem;
     if (empty($wp_filesystem)) {
         $wp_filesystem = new WP_Filesystem_Direct(null);
     }
     $pluginUpgrader = new Plugin_Upgrader();
     $thePlugin = get_plugin_data($slug);
     if ($thePlugin != null && $thePlugin != '') {
         $pluginUpgrader->delete_old_plugin(null, null, null, array('plugin' => $slug));
     }
     ob_end_clean();
     die(json_encode(array('result' => 'SUCCESS')));
 }