Beispiel #1
0
 function test_should_update_plugin()
 {
     Ak::directory_delete(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib');
     $this->assertFalse(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
     $this->PluginManager->updatePlugin('acts_as_versioned');
     $this->assertTrue(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
 }
Beispiel #2
0
 public function clearAll()
 {
     if (AK_LOG_EVENTS) {
         $Logger =& Ak::getLogger();
         $Logger->message('Clearing all database settings from cache');
     }
     Ak::directory_delete(AkDbSchemaCache::getCacheDir());
 }
Beispiel #3
0
 function Test_directory_delete()
 {
     $this->assertFalse(!Ak::directory_delete('ak_test_folder'));
     $this->assertFalse(Ak::directory_delete('../../'));
     $this->assertFalse(Ak::directory_delete('..\\..\\'));
     $this->assertFalse(Ak::directory_delete(' '));
     $this->assertFalse(Ak::directory_delete('/'));
     $this->assertFalse(Ak::directory_delete('./'));
 }
Beispiel #4
0
 function directory_delete($dir_name, $options = array())
 {
     $default_options = array('ftp' => defined('AK_DELETE_FILES_USING_FTP') && AK_DELETE_FILES_USING_FTP, 'base_path' => AK_BASE_DIR);
     $options = array_merge($default_options, $options);
     $sucess = true;
     $dir_name = Ak::_getRestrictedPath($dir_name, $options);
     if (empty($dir_name)) {
         return false;
     }
     if ($options['ftp']) {
         require_once AK_LIB_DIR . DS . 'AkFtp.php';
         return AkFtp::delete($dir_name);
     } else {
         $items = glob($options['base_path'] . DS . $dir_name . "/*");
         $hidden_items = glob($options['base_path'] . DS . $dir_name . "/.*");
         $fs_items = $items || $hidden_items ? array_merge((array) $items, (array) $hidden_items) : false;
         if ($fs_items) {
             $items_to_delete = array('directories' => array(), 'files' => array());
             foreach ($fs_items as $fs_item) {
                 if ($fs_item[strlen($fs_item) - 1] != '.') {
                     $items_to_delete[is_dir($fs_item) ? 'directories' : 'files'][] = $fs_item;
                 }
             }
             foreach ($items_to_delete['files'] as $file) {
                 Ak::file_delete($file, $options);
             }
             foreach ($items_to_delete['directories'] as $directory) {
                 $sucess = $sucess ? Ak::directory_delete($directory, $options) : $sucess;
             }
         }
         return $sucess ? @rmdir($options['base_path'] . DS . $dir_name) : $sucess;
     }
 }
Beispiel #5
0
 function directory_delete($dir_name, $options = array())
 {
     $default_options = array('ftp' => defined('AK_DELETE_FILES_USING_FTP') && AK_DELETE_FILES_USING_FTP, 'base_path' => AK_BASE_DIR);
     $options = array_merge($default_options, $options);
     $sucess = true;
     $dir_name = str_replace('..', '', rtrim($dir_name, '\\/. '));
     if ($dir_name == '') {
         return false;
     }
     $dir_name = trim(str_replace($options['base_path'], '', $dir_name), DS);
     if ($options['ftp']) {
         require_once AK_LIB_DIR . DS . 'AkFtp.php';
         $dir_name = trim(str_replace(array(DS, '//'), array('/', '/'), $dir_name), '/');
         return AkFtp::delete($dir_name);
     } else {
         if ($fs_items = glob($options['base_path'] . DS . $dir_name . "/*")) {
             $items_to_delete = array('directories' => array(), 'files' => array());
             foreach ($fs_items as $fs_item) {
                 $items_to_delete[is_dir($fs_item) ? 'directories' : 'files'][] = $fs_item;
             }
             foreach ($items_to_delete['files'] as $file) {
                 Ak::file_delete($file, $options);
             }
             foreach ($items_to_delete['directories'] as $directory) {
                 $sucess = $sucess ? Ak::directory_delete($directory, $options) : $sucess;
             }
             return $sucess;
         }
         return rmdir($options['base_path'] . DS . $dir_name);
     }
 }
Beispiel #6
0
 function test_remove_plugin()
 {
     Ak::directory_delete(AK_PLUGINS_DIR . DS . 'acts_as_versioned');
 }
Beispiel #7
0
 public function test_should_delete_nested_directories_when_include_hidden_files()
 {
     $tmp_dir = AK_TMP_DIR . DS . Ak::randomString();
     $hidden_tmp_dir = $tmp_dir . DS . '.hidden';
     Ak::make_dir($tmp_dir, array('base_path' => AK_TMP_DIR));
     Ak::make_dir($tmp_dir . DS . '.hidden', array('base_path' => AK_TMP_DIR));
     $this->assertTrue(is_dir($hidden_tmp_dir), 'Could not create test directory ' . $hidden_tmp_dir);
     $this->assertTrue(Ak::directory_delete($tmp_dir, array('base_path' => AK_TMP_DIR)));
     clearstatcache();
     $this->assertFalse(is_dir($tmp_dir));
 }
Beispiel #8
0
    /**
     * Uninstalls an existing plugin
     * 
     * Plugins can have an Akelos installer at located at "plugin_name/installer/plugin_name_installer.php"
     * If the installer is available, it will run the "PluginNameInstaller::uninstall()" method, which will trigger
     * all the down_* methods for the installer.
     * 
     * @param  string  $plugin_name Plugin name
     * @return void  
     * @access public
     */
    function uninstallPlugin($plugin_name)
    {
        $plugin_name = Ak::sanitize_include($plugin_name, 'high');
        $this->_runInstaller($plugin_name, 'uninstall');
        Ak::directory_delete(AK_PLUGINS_DIR.DS.$plugin_name);

        if($this->_shouldUseSvnExternals()){
            $this->_uninstallExternals($plugin_name);
        }
    }
Beispiel #9
0
 function test_should_delete_nested_directories_when_include_hidden_files()
 {
     $dir_name = AK_TMP_DIR . Ak::randomString();
     Ak::make_dir($dir_name);
     Ak::make_dir($dir_name . DS . '.hidden');
     $this->assertTrue(is_dir($dir_name), 'Could not create test directory ' . $dir_name);
     $this->assertTrue(Ak::directory_delete($dir_name));
     clearstatcache();
     $this->assertFalse(is_dir($dir_name));
 }