can someone help me convert this to php please

the code i have works great in vb6 i can for the life of me figure out how to get this all to work in php tho

heres the working code in vb6
---------vb6 code ---------
  Dim i As Long
  Dim USERS As Object
   
    Set USERS = CreateObject("MailServerX.Users")
    Open "USERLIST.TXT" For Output As #1
        For i = 0 To USERS.Count - 1
            'Print #1, "Is User Active: " & USERS.Items(i).Active
            'Print #1, "Last Login Time: " & USERS.Items(i).LastLoginTime
            'Print #1, "UserName: " & USERS.Items(i).UserName
            'Print #1, "Password: " & USERS.Items(i).Password
            'Print #1, "**-----------------------------------**"
        Print #1, "" & USERS.Items(i).Active & "," & USERS.Items(i).LastLoginTime & "," & USERS.Items(i).UserName & "," & USERS.Items(i).Password
        Next i
    Close #1
    MsgBox "Operation Complete"
    Set USERS = Nothing
------------ end code ----------

heres a working php code
it gets a users email from the mail box

------------- php code ------------
function msgBox($content){
$pass = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#3399CC\"><tr><td>$content</td></tr></table>";
return $pass;
}
function getMail($user){
$MailBox = new COM("MailServerX.MailBox");
$MailBox->UserName= $user;
for($i = 0; $i < $MailBox->Count; $i++){
$send = msgBox($MailBox->Items($i));
print $send."<BR>";
};
}

------------- end php code ----------

a second working example

------------ php code----------
$Users = new COM("MailServerX.Users");
print "Total Users: {$Users->Count}";
print "<br>";
---------- end php code --------


heres the code ive tryed to no avail
----------- not working php code ---------
function msgBox($content){
$pass = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#3399CC\"><tr><td>$content</td></tr></table>";
return $pass;
}
function getMail($users_email){
$Users = new COM("MailServerX.Users");
print "Total Users: {$Users->Count}";
print "<br>";


$MailBox = new COM("MailServerX.User");
#$MailBox->UserName= $user_email;
for($i = 0; $i < $Users->Count; $i++){
$send = msgBox($MailBox->Items($i)->Password);
print "UsersPassword: ";
print $send."<BR>";
};
}
?>

-------- end not working php code --------
i get an error of:
Fatal error: Call to undefined method com::Items() in C:\home\www\argodragonsoftware.info\php\getpassword.php on line 23


any help would be great i DO NOT want to out put this toa  file the screen would be fine and i do not need a essage box i just want the info echoed to the screen is all and for the life of me i cant get it...

thanks for any help
Pern
JohnnyAsked:
Who is Participating?
 
hernst42Connect With a Mentor Commented:
So got it work. (PHP5.0.1 php.exe) Maybe you just accessed the wrong attributes.

$Users = new COM("MailServerX.Users");
print "Total Users: {$Users->Count}\n";

$MailBox = new COM("MailServerX.Mailbox");
for($i = 0; $i < $Users->Count; $i++){
    $MailBox->UserName = $Users->Items($i)->UserName;
    echo "UserName       : " . $Users->Items($i)->UserName ."\n";
    echo "Password       : " . $Users->Items($i)->Password ."\n";
    echo "UserName       : " . $Users->Items($i)->UserName ."\n";
    echo "Last Login Time: " . $Users->Items($i)->LastLoginTime ."\n";
    echo "Mails          : " . $MailBox->Count . "\n";
    // dump all messages of that user
    for($j = 0; $j< $MailBox->Count; ++$j) {
        echo $MailBox->Items($j) . "\n";
    }
    echo "\n--------------------------------------------\n";
  }

P.S. sorry for the delay, but I have been very busy the last days.
0
 
hernst42Commented:
this line does make the problems:
msgBox($MailBox->Items($i)->Password);
might be :
msgBox($MailBox->Items[$i]->Password);

for further inspection a line var_dump($MailBox) might be usefull to see the content of that object. Put that lin before the mentioned line.

are you using PHP5?
0
 
JohnnyAuthor Commented:
how do i do a  line var_dump($MailBox)?? i can print the contents of $MailBox like Print "MailBox: " . $MailBox; i dont know how else to do that...

this gets an error of
$send = msgBox($MailBox->$users_email->Password);

error:
Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `postmaster@dragonsworkshop.com': Unknown name. ' in C:\home\www\argodragonsoftware.info\php\getpassword.php:24 Stack trace: #0 C:\home\www\argodragonsoftware.info\php\getpassword.php(44): getMail('postmaster@drag...') #1 {main} thrown in C:\home\www\argodragonsoftware.info\php\getpassword.php on line 24

this gets an error of
$send = msgBox($MailBox->Items[$i]->Password);

error:
Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `Items': Unknown name. ' in C:\home\www\argodragonsoftware.info\php\getpassword.php:24 Stack trace: #0 C:\home\www\argodragonsoftware.info\php\getpassword.php(44): getMail('postmaster@drag...') #1 {main} thrown in C:\home\www\argodragonsoftware.info\php\getpassword.php on line 24

im useing PHP Version 5.0.1

thx for help so far
Pern
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
hernst42Commented:
To add debugging information change the following code:
$MailBox = new COM("MailServerX.User");
#$MailBox->UserName= $user_email;
for($i = 0; $i < $Users->Count; $i++){
to:
$MailBox = new COM("MailServerX.User");
#$MailBox->UserName= $user_email;
var_dump($MailBox);
for($i = 0; $i < $Users->Count; $i++){

Which Software is needed to create such a MailServerX.User so I can try it on my windows-box
0
 
JohnnyAuthor Commented:

var dump as fallows:(var_dump($MailBox);)

---dump ---
object(com)#2 (0) { }
---end dump---
------------------------------------------------------
mailserverx.user is part of a e-mail damond  its called argosoft email server...

the pro version is the only one that alows active x dll interaction...

the demo expires in 30 days
http://www.argosoft.org/dl/default.aspx?filename=mspro.exe

there is a help file located in the directory called
mlsrvx.hlp
this give vbs examples

the file mlsrvx.dll has to be reged (can be done from inside email servers admin panel
anything else please ask me.
thx for help so far
Pern
0
 
mail-routerCommented:
Hi

You are trying to access a object reference, which is not a object value! VB, ASP, .NET do not work the same way as PHP. You have to assign the reference to a variant, and then use the variant to access the object value!

I have a class file that can do what you want, but I have it at work. I made it a few months ago for a client that is using the ArgoSoft mail server! I don't have a help file with the properties and methods here or I would give you an example. I am going to go by the office in the morning and I will post some examples for you then!

So you understand the differences between PHP and VB or ASP, I will give you a simple example of a object reference!

Lets say you have a spell checker that is written as a COM object .dll file....

In VB you would do the following
//VB Script example

Dim SPELL, text, word, cursor, options, result, otherword

Set SPELL = Server.CreateObject("SpellServer.SpellCheck")

result = SPELL.CheckText(CStr(text), CLng(24941), CLng(options), CStr(""), CStr(""), cursor, word, otherWord)

// end VB example

If you look at the above example you will see that I first call or load the object, then I call a object method "Check.Text"!

In VB the reference is stored in the servers scope, so accessing a value in the method is as easy as....

Response.Write(cursor) or to access the return code held in "result", I just need to do this....

Response.Write(result)

PHP, gives you complete access but you have to access them differently because it is a separate process that is not wrapped to the server!

// PHP example.....

$this = new COM ( 'SpellServer.SpellCheck' );

$text = new VARIANT ( $text, VT_BSTR );
$other = new VARIANT ( $other, VT_BSTR );
$start = new VARIANT ( $start, VT_INT );
$word = new VARIANT ( $word, VT_BSTR );
$result = $this->CheckText ( $text, $out['ul'], $out['uo'], $dic, $out['ignore'], $start, $word, $other );

Then to echo each reference value you could do the following....

echo $text->value;
echo $start->value;
echo $word->value;
echo $other->value;

// end PHP example...

Array references are also handled differently!

Check back tomorrow for some working example I will post


MR
0
 
JohnnyAuthor Commented:
that would be great and thanks mail-router i can get it in vbs and vb6 just fine a working example would be fantastic with a class evan better more then i could have dreamed of...

thanks ever so much

Pern
0
 
JohnnyAuthor Commented:
AHHHHH!!!!

I lost the nice person that was helping me figure this out, hernst42!!!

I also lost mail-router a person that informed me he had the code at there work....


darn darn darn, herman munster style...and i so wanted to get this all to work....


:( maybe i can turn this frown to a :) and be happy again with the answer!!!...

looking for you both
Pern
aka Johnny
0
 
JohnnyAuthor Commented:
hernst42,

if you have any other examples that be great too

im gonna try and figure out how to get JUST THE ONE users info here ina  bit..
im gonna place you in the credits if thats ok of the shareware program im devloping..hopefully agrosoft will post my program...im making a site for all this now i will also place your name there too...if thats ok...

thanks again
Johnny
aka Pern
0
 
JohnnyAuthor Commented:
mail-router,

id still love the code you have the more things i can do the better...

ill extend the same to you for crdit if youd like...as well as post another question for points for you if you wish as you did help and was willing to provide MORE then what i asked for(always a plus in my book) so if you ever get back to me ill be happy to works something out..

Im awarding the points to hernst42 as he did answer the question


Johnny
aka Pern
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.