Automated Client Kick, how to delete...

Discussion in 'Tips/Tricks/Mods' started by pchotfix, Apr 14, 2008.

  1. pchotfix

    pchotfix New Member

    Hi speciallists,

    i want to automate delete all webs on my server, who made 0-traffic in at least two month.
    I wrote a php-script with the remoting-extension that puts out all the matching Webs. But....

    I got the information from fields doc_id,web_id,monat and bytes_web from the isp_traffic table.
    But witch collums are referenced to my clients??
    The isp_kunde table doesn´t have a web_id nor a doc_id field.

    then, if cou can tell me the right reference, in witch order must i proceed the delete? first web, then DB, than mailacounts, than client...???

    regards
    Rene´
     
  2. pchotfix

    pchotfix New Member

    Automate Web and Client delete

    ok, I got the list of webs (with thair web_id) who have zero-traffic.
    By the web_id i can use the Remoting API to...
    ...list and delete the users from the web :)
    ...list and delete the Db´s from the web :)

    BUT

    How to delete the client? :confused:
    The Remoting API requires "kunde_title". How or where to get this information?

    a little help please!

    Does anyone have a database-reference of ISPconfig?
     
  3. grandpagenocide

    grandpagenocide New Member

    kunde title is usually 'admin' or the reseller name, but why not just delete the client which will remove web and db's. look at the example scripts.
    as far as the db entry i believe your looking for isp_nodes and field title
     
    Last edited: Apr 18, 2008
  4. pchotfix

    pchotfix New Member

    Required field

    Your right grandpagenoicide, The title-field seems to be the title which i need for the script.... BUT: where is the reference to the right webs?

    My script analyses the values of the isp_traffic table. there are only references to web_id and doc_id, which seems to be NOT the same as the ones in isp_nodes..... very confusing....:confused:

    Do you know the right references?

    Thanks,
    Rene´
     
  5. grandpagenocide

    grandpagenocide New Member

    renee Ill poke around the db when i get a chance but I thought you already had those set up, if you have a traffic value of 0 for the period for that give site, then delete the whole client, which will delete the webs and db's under that client
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    doc_id is always the primary index of a table, so the doc_id of one table is normally not the doc_id of another table. If I remember correctly:

    isp_traffic.web_id = isp_isp_web.doc_id
     
  7. pchotfix

    pchotfix New Member

    have i all i must have?

    Thank you till, and thank you grandpagenocide but...
    From the isp_traffic table i get the web_id witch is the reference to the 0-KB web.
    So far so good.
    But how to know witch client owns the web?
    The isp_nodes table hold the "title"-information i need to delete the client.
    But i don´t find the reference to the web_id i have....

    i´m still confused. can you please explain me the way i need?

    regards
    Rene´
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    The isp_nodes and isp_web table are linked trough the doc_id and doctype_id columns:

    isp_nodes.doc_id = isp_isp_web.doc_id and isp_nodes.doctype_id = isp_isp_web.doctype_id
     
  9. pchotfix

    pchotfix New Member

    worst case ;-)

    thank you till,

    i finaly found the reference i need. now i know the way to get my param "title" i must have.

    BUT.... worst case ;-)

    No suxess, No error (!), No solution...

    first i thought it is my script, but i have the symtom when i use the remoting-example.php too.
    I hard-coded the client´s "title", then i run the script. But he did't delete anything, and gave me non comment.

    Please, where must i restart debugging now?
    does soap or isp_config any logging?

    where could i see whats wrong?

    Thanks a lot for your suggestions!

    Rene´
     
  10. pchotfix

    pchotfix New Member

    half step further

    hi @all,

    i have made several tests with the remoting test-script.
    get_client (kunde_get) works everytime with my kunde_title-value
    but
    delete_client (kunde_delete) works never with the same value!

    can you please confirm that with your enviroment?!

    how to go on? has anybody successfully deleted clients? :confused:

    is this a bug?
    i have found in ispconfig_kunde.lib.php the function "kunde_delete" (line 628) but its parameters are $session and $params, not $service and $params.

    ÄIRG!

    PLEASE HELP ME! :eek:
     
  11. krakoukas

    krakoukas New Member

    Same remoting client deletion (kunde_delete) problem

    I am managing user accounts and when trying to remove a bad client via remoting and kunde_delete with 'kunde_title' param

    Code:
    // Deleting Client (always there)
      $params = array ( 'sid' => $session_id,
         'module' => 'kunde',
         'function' => 'kunde_delete',
         'params' => array ( 'kunde_title' => $user_id));
    
    if ( $soap_client->call('service',$params) ) $mylog .= "<br> Removal of Client ".$user_id." -> OK";
    if($err = $soap_client->getError()) die("Error removing client: ".$user_id." ".$err);
    
    In fact, sometimes it goes well (removing client, web and user), but sometimes, it removes web or user from another client.
    This is very annoying and force me to still remove client by hand (for control and undelete that fortunately works) !

    I my opinion, it may happens when Client has no User or No Web when deleted then it gets another from around.
    How could I debug this part of code? Could you tell me which function is used and where it is so that I can put error_log in it...

    I send an SOS to anybody having the same problem and maybe found a solution or could give me the keys to solve it?

    Thanks
    Fred
     
  12. grandpagenocide

    grandpagenocide New Member

    krakoukas

    Are you titling the web and user with the same title? kunde_title?
    for user ID are you attempting to use the db numeric ID or the actual username?

    odd questions, but i have used remote and consistantly get the same results
     
  13. krakoukas

    krakoukas New Member

    All my accounts are created the same way:
    client_add ("user")
    web_add("Site user")
    user_add ("user")

    Then I use these _title fields as reference for remoting access.

    Do you know in which ISPConfig file(s) does this deletion actions happens?
    I could try to add some breakpoints...
    Thanks for your concern
     
  14. grandpagenocide

    grandpagenocide New Member

    i believe your looking for /home/admispconfig/ispconfig/lib/classes/ispconfig.kunde.lib.php

    its been a while since i have done any patching on the remoting package, Im a little out of date with ISPConfig, but I thought it was going to be included in current releases?

    you may want to look through the remoting package before playing around with it.
     
  15. krakoukas

    krakoukas New Member

    As I was deleting my client with "kunde_title", I have tried to modifiy my code to use "kunde_id", making a client_list on my client remove page to get this id.
    The problem is stilll the same!

    It seems to happen when Client lacks his Site or his User... Maybe there is a mistake when during Client deletion code when trying to find attached Site and User??

    I haven't found where it is happening yet...
    Is it remoting or ispconfig_kunde.lib.php that makes this sanity checks?

    I hope I will be able to spot my problem, Administration takes me too long with this deletion side effect and can be very dangerous if I don't see the mistake and empty recycle bin...
     
  16. krakoukas

    krakoukas New Member

    Foud a logical relationship into illogical behaviour...

    Looking closely to my Client deletion side effect problem, I discovered that actions seems always the same.
    Web and User falsely deleted have precise IDs.

    For example:

    So for a removed WebID : WebID - 2, UserID - 2 and UserID + 2 are also put in Trash
    I can see them in del_status table, with no "d" in status.

    I hope it could help anyone for helping me :confused:
     

Share This Page