Solved

can someone help me convert this to php please

Posted on 2004-09-13
10
268 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
  • 6
  • 3
10 Comments
 
LVL 48

Expert Comment

by:hernst42
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Johnny
Comment Utility

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
Comment Utility
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Johnny
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now