Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

can someone help me convert this to php please

Posted on 2004-09-13
10
Medium Priority
?
289 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:Johnny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12046297
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
 

Author Comment

by:Johnny
ID: 12047580
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
 
LVL 48

Expert Comment

by:hernst42
ID: 12047844
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Johnny
ID: 12048976

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
 

Expert Comment

by:mail-router
ID: 12050245
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
 

Author Comment

by:Johnny
ID: 12050604
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
 

Author Comment

by:Johnny
ID: 12075172
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
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 12078231
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
 

Author Comment

by:Johnny
ID: 12083730
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
 

Author Comment

by:Johnny
ID: 12083748
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question