Thursday, August 25, 2011

Removing a directory using XML-API

December 30, 2010 by  
Filed under cPanel

Leave a Comment

In the previous article, we have shown you how to connect to cPanel’s front end (2082/2083) ports. In this article we will show you how to delete a directory in your file system using XML-API in PHP.

Let’s say you want to delete a directory named ‘deleteme‘ in public_html directory.  So the path is /home/USER/public_html/deleteme. However, we don’t need to bother with /home/USER part. We just need to provide the path started from public_html.

For deleting, we will use api2 query’s Fileman module! Here is how you should execute it:

$directory = ‘public_html/deleteme’;

$result = $cpanel->api2_query(‘cPanel Username’, ‘Fileman’, ‘fileop’, array(‘op’=>’unlink’,'sourcefiles’=>$directory));

That’s it!

If you are not still clear how to use XML-API Service, here is more details.


require_once(‘xmlapi.php’);

$cpanel = new xmlapi();

$cpanel->set_host(‘CP_DOMAIN’);
$cpanel->set_port(2083);
$cpanel->password_auth(‘CP_USERNAME’, ‘CP_PASSWORD’);

$directory = ‘public_html/deleteme’;

$result = $cpanel->api2_query(‘CP_USERNAME’, ‘Fileman’, ‘fileop’, array(‘op’=>’unlink’,'sourcefiles’=>$directory));


GD Star Rating
a WordPress rating system
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Related posts:

  1. Effective Solutions for 500 error (Premature End of Script Headers)
  2. cPanel JailShell, Unmount and Clean Virtfs
  3. How to connect cPanel’s ports using XML-API (PHP Class)?
  4. Delete some specific files from all subdirectories
  5. Creating FTP accounts in Enkompass control panel!

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!
Click here to cancel reply.