Executing a function from a 'foreign' script

Discussion in 'PHP' started by archard, Jul 23, 2008.

  1. #1
    I was wondering if it's possible to fire a function that resides in a completely separate script from the one currently being executed.

    For example, I am using Drupal and phpBB, and I have a module that integrates certain aspects of each like user sessions, and certain profile information. But if I want to do something like add or delete a user, the only thing I can do is attempt to imitate the SQL that the other script uses. It would be REALLY cool if I could include the phpBB user delete function in Drupal's user delete function, so that when I execute Drupal's user delete function, phpBB's user delete function is also executed just like it would be if I were actually 'using' phpBB's script.

    Is there a reasonable way to do this?
     
    archard, Jul 23, 2008 IP
  2. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #2
    Just use the include directive to include the function file in whichever file you are calling the function from. For example, I don't know what page the delete user function resides in in phpbb, but you can include the file from your page:

    
    include("/phpbbusers.php");
    
    Code (markup):
    And then just call the function: deleteUser(UserId) - or however it's done with phpBB. But when you include a file you inherit all the functions in that file.
     
    itcn, Jul 24, 2008 IP
  3. juust

    juust Peon

    Messages:
    214
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If phpBB has an XML handler like wordpress (xmlrpc.php), you could post transactions to it and operate a forum on remote-control, also on other servers. Includes are simpler.
     
    juust, Jul 24, 2008 IP