The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Delete forwarder using PHP

Discussion in 'General Discussion' started by WoodyUK, Jan 9, 2005.

  1. WoodyUK

    WoodyUK Member

    Joined:
    May 2, 2004
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I have a script (obtained on this forum last year) that adds / deletes POP boxes using PHP. I have added a routine to create a forwarder. However, I cannot get one to work that deletes a forwarder. The code I have is:

    Code:
    deletefwd('spam@mydomain.co.uk','forwarded address')
    */
    function deletefwd($email,$forwarded)
    {
    $email=$email . "=" . $forwarded;
    global $cpaneltheme,$cpanelpass,$cpaneluser,$host;
    $request_url="/frontend/$cpaneltheme/mail/dodelfwd.html?email=$email";
    $socket = fsockopen($host,2082,$errno,$errstr);
    if (!$socket) {
       echo "$errstr ($errno)<br />\n";
    }
    $authstr = "$cpaneluser:$cpanelpass";
    $pass = base64_encode($authstr);
    $in = "GET $request_url\r\n HTTP/1.0\r\nAuthorization: Basic $pass \r\n".
    "Connection: Close\r\n" . 
    "\r\n";
    fputs($socket,$in);
    
    $result_from_action="";
    // for debug
    while (!feof($socket)) {
    $result_from_action.=fgets($socket, 128);
       }
    fclose($socket);
    }
    I know the URL for the deletion needs to be /frontend/$cpaneltheme/mail/dodelfwd.html?email=spam@mydomain.co.uk=forwarded address but can't get it to work. I have tried various ways of getting the $email to concatenate into the required string, but all fail. Any ideas? I think it's the second '= in the query string causing the issue, but can't remember how to avoid this.

    Thanks
     
  2. WoodyUK

    WoodyUK Member

    Joined:
    May 2, 2004
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    hmmmm

    I have now added a line that echoes out the $request_url variable. It shows as /frontend/rvblue/mail/dodelfwd.html?email=spam@mydomain.co.uk=forward@otherdomain.com which, as far as I can see is correct. - the space in the otherdomain.com has been added here. It is not present in the script output.

    If the add forwarder script is working, just by modifying the addpop script, then surely modifying the delpop script, the delforwarder should work? Or am I missing something really obvious?
     
    #2 WoodyUK, Jan 9, 2005
    Last edited: Jan 9, 2005
  3. WoodyUK

    WoodyUK Member

    Joined:
    May 2, 2004
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    anyone? It's starting to drive me mad now.......
     
  4. fwwebs

    fwwebs Well-Known Member

    Joined:
    Feb 16, 2004
    Messages:
    329
    Likes Received:
    0
    Trophy Points:
    16
    Does this work:
    PHP:
    http://username:password@domain.tld:2082/frontend/theme/mail/dodelfwd.html?email=spam@mydomain.co.uk
    If so try this:

    PHP:
    $delfwd="http://username:password@domain.tld:2082/frontend/theme/mail/dodelfwd.html?email=spam@mydomain.co.uk";
    fopen ($delfwd,"r");
     
  5. WoodyUK

    WoodyUK Member

    Joined:
    May 2, 2004
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    nope. Afraid that didn't work.

    There must be a way of doing this, since the same script will delete a POP account.
     
Loading...

Share This Page