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.

Accounting.php issue

Discussion in 'General Discussion' started by monotreme, Sep 15, 2004.

  1. monotreme

    monotreme Member

    Joined:
    Sep 14, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I am going to try to be CRYSTAL CLEAR here about what I want to do, what I tried, and what happened because a lot of the posts on this topic are vague and hand wavy. like "Use Accounting.php" So pardon the verbosity.

    I want a PUBLIC webpage called lists.php that gives a list of just the accounts and their urls, not all the data that yuo get inside cpanel. But I figure once I get the data I can massage it. GETTING IT is the problem.

    I tried the following: which I found on
    http://www.cpanel.net/docs/whm/UsingCpanelAccountingPhpModule.htm
    PHP:
    <?php
    require '/usr/local/cpanel/Cpanel/Accounting.php.inc';
    $host "localhost";
    $user "<USERNAME HERE>";
    $accesshash '<REMOTE ACCESS KEY HERE>';

    $accts listaccts($host,$user,$accesshash,0);
    print_r($accts);
    //$pkgs = listpkgs($host,$user,$accesshash,0);
    //print_r($pkgs);

    ?>
    (I commented listpkgs)
    It prints out a bunch of html cruft but no account data.

    Question:
    The username that's the one I use to access cpanel yes?
    The remote access key would that be the same password string I use to log into Cpanel?
    Is it a problem that I want this on a PUBLIC page
    (accessible vya http://myserver.com/lists.php

    Question: It says "This module requires the curl+ssl PHP module to be installed." but that's not what the program code seems to imply.

    This is my php config

    './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-xml' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--enable-magic-quotes' '--with-mysql' '--enable-discard-path' '--with-pear' '--enable-sockets' '--enable-track-vars' '--enable-versioning' '--with-zlib'

    Is THIS my problem? and if so how do I solve it? I don't seem to have curl here.

    I found an OOP version of the Accounting.php
    I've looked at the logic for the class and it seems to go like this:
    If you don't have curl then you better have sockets enabled (which it appears I do), and you have to be using usessl=0
    which I am. So maybe if I try the class instead of the procedureal way, it will work:
    OK here I go
    here is the class version of the same thing: (I made this up.)

    PHP:
    <?php
    require '/usr/local/cpanel/Cpanel/Accounting-class.php.inc';
    $accounting = new accounting();
    $accounting->host='localhost';
    $accounting->user='<me>';
    $accounting->accesshash='<mypass>';
    $accounting->usessl=0;
    $accts=$accounting->listaccts();
    echo 
    "<pre>"print_r($accts); echo "</pre>";
    ?>
    Basically gives me the same cruft as before.
    It seems odd that their doesn't appear to be a constructor for this class.
    The weird thing about this is it doesn't seem to be failing, it just seems to be giving
    out crap.

    BTW this is what I get for the answer:

    Array
    (
    [<html>] => Array
    (
    [0] =>
    )

    [<head>] => Array
    (
    [0] =>
    )

    [<title>cPanel Login</title>] => Array
    (
    [0] =>
    )

    [<meta http-equiv] => Array
    (
    [0] => "Content-Type" content
    )

    [<link rel] => Array
    (
    [0] => "shortcut icon" href
    )

    [<script language] => Array
    (
    [0] => "JavaScript">
    )

    [<!--] => Array
    (
    [0] =>
    )

    [function MM_swapImgRestore() { //v3.0] => Array
    (
    [0] =>
    )

    [ var i,x,a] => Array
    (
    [0] => document.MM_sr; for(i
    )

    [}] => Array
    (
    [0] =>
    )

    [function MM_preloadImages() { //v3.0] => Array
    (
    [0] =>
    )

    [ var d] => Array
    (
    [0] => document; if(d.images){ if(!d.MM_p) d.MM_p
    )

    [ var i,j] => Array
    (
    [0] => d.MM_p.length
    [1] => a
    )

    [ if (a.indexOf("#")!] => Array
    (
    [0] => 0){ d.MM_p[j]
    )

    [function MM_findObj(n, d) { //v3.0] => Array
    (
    [0] =>
    )

    [ var p,i,x; if(!d) d] => Array
    (
    [0] => document; if((p
    )

    [ d] => Array
    (
    [0] => parent.frames[n.substring(p+1)].document; n
    )

    [ if(!(x] => Array
    (
    [0] => d[n])&&d.all) x
    )

    [ for(i] => Array
    (
    [0] => 0;!x&&d.layers&&i<d.layers.length;i++) x
    )

    [function MM_swapImage() { //v3.0] => Array
    (
    [0] =>
    )

    [ var i,j] => Array
    (
    [0] => 0
    [1] => x
    [2] => a
    )

    [ if ((x] => Array
    (
    [0] => MM_findObj(a))!
    )

    [//-->] => Array
    (
    [0] =>
    )

    [</script>] => Array
    (
    [0] =>
    )

    [</head>] => Array
    (
    [0] =>
    )

    [<body>] => Array
    (
    [0] =>
    )

    [<table width] => Array
    (
    [0] => "603" border
    )

    [ <tr valign] => Array
    (
    [0] => "top">
    )

    [ <td> ] => Array
    (
    [0] =>
    )

    [ <table width] => Array
    (
    [0] => "100%" border
    )

    [ <tr> ] => Array
    (
    [0] =>
    )

    [ <td height] => Array
    (
    [0] => "2" colspan
    )

    [ <table width] => Array
    (
    [0] => "100%" border
    )

    [ <tr> ] => Array
    (
    [0] =>
    )

    [ <td><img src] => Array
    (
    [0] => "/unprotected/images/bottom_label.gif" width
    )

    [ </tr>] => Array
    (
    [0] =>
    )

    [ </table>] => Array
    (
    [0] =>
    )

    [ </td>] => Array
    (
    [0] =>
    )

    [ </tr>] => Array
    (
    [0] =>
    )

    [ <tr>] => Array
    (
    [0] =>
    )

    [ <td align] => Array
    (
    [0] => "right"><img src
    )

    [ <td width] => Array
    (
    [0] => "135" nowrap align
    )

    [ <tr valign] => Array
    (
    [0] => "top">
    )

    [ <td colspan] => Array
    (
    [0] => "3">
    )

    [ <tr valign] => Array
    (
    [0] => "top">
    )

    [ <td>] => Array
    (
    [0] =>
    )

    [<center><h1>Web Host Manager Login</h1><table border] => Array
    (
    [0] => 2><tr><td><form action
    )

    [<tr><td>Password</td><td><input type] => Array
    (
    [0] => password name
    )

    [ size] => Array
    (
    [0] => 16></td></tr><tr><td colspan
    )

    [ value] => Array
    (
    [0] => "Login"></div></td></tr></table></form></td></tr></table></center><br></td></tr></table></td></tr><tr align
    )

    [ <tr align] => Array
    (
    [0] => "center">
    )

    [ </table>] => Array
    (
    [0] =>
    )

    [ </td>] => Array
    (
    [0] =>
    )

    [ </tr>] => Array
    (
    [0] =>
    )

    [</table>] => Array
    (
    [0] =>
    )

    [</body>] => Array
    (
    [0] =>
    )

    [</html>] => Array
    (
    [0] =>
    )

    )

    This looks like it is trying to place each line of the html for the login page in an array.
    So maybe it doesn't like being run as apache.

    So I'll try one more thing: I'll run this as root in CLI php
    Well it doesn't like that. It prints the <pre></pre> that is all.

    I have been head banging on this for about 4 hours. I am out of ideas.

    Can ANYONE PLEASE tell me PRECISELY AND COMPLETELY with no handwaving or assumptions what I am doing wrong?

    Thank you. :eek: :confused: :mad:
     
Loading...

Share This Page