Re: [PHP] mcrypt trouble, still

2001-08-23 Thread Andrew Libby

Dominic, 
These locations can be set by in php.ini or passed as parameters to
the mcrypt functions they pretain to (notably those used to initialize).

Andy

On Thu, Aug 23, 2001 at 07:24:42AM -0500, Dominic Schanen wrote:
 Well, in response to my previous post and its reply, the server
 administrator tried reinstalling mcrypt and did the testing during the
 install and it all seemed to work for him there. However, I still get the
 error:
 
 Warning: mcrypt module initialization failed
 
 So, now my question is this. In the phpinfo file, all the ciphers and modes
 are listed fine and it shows that mcrypt is enabled. However, for the
 directives mcrypt.algorithms_dir and mcrypt.modes_dir, they have no local or
 master value. Is this something that needs to be set in phpinfo to point at
 the mcrypt installation? Thanks.
 
 --
 Dominic
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mcrypt trouble

2001-08-21 Thread Andrew Libby

Dominic,
I'd start by checking the libmcrypt installation.
If you're building from source, prior to your installation
check that [mcrypt-src-dir]/src/cipher_test runs without 
error.  If that succedes, install libmcrypt (and mcrypt) and
then attempt to test with the command line.  Start by listing
ciphers and modes.  Then attempt to encrypt and decrypt something.
Once you've verified that the underlying code is working, then
attempt to list the ciphers and modes with PHP functions.  In general
the mcrypt examples given by the php manual at php.net/manual were
enough to get me started.

Note, I've experienced problems on Solaris and Linux with the modules
not being found (cipher .so's).  Sometimes it's as easy as setting 
directories in php.ini, sometimes I've had to get into the libmcrypt code.

Good luck.

Andy

On Tue, Aug 21, 2001 at 09:16:22AM -0500, Dominic Schanen wrote:
 Hello,
 
 I'm trying to do mcrypt encryption but I continue to get the following
 error:
 
 Warning: mcrypt module initialization failed
 
 and this is the line of code that I get the error from:
 
 $string = mcrypt_cbc(MCRYPT_DES, $key, $test, encrypt);
 
 I've also tried several different version of using the function
 mcrypt_encrypt as well but nothing seems to work. In my phpinfo file, this
 is what I have for the mcrypt module:
 
 Version: 2.4.x
 
 Supported Ciphers:
 cast-128 cast-256 enigma xtea arcfour panama safer-sk64 saferplus des
 tripledes blowfish gost rc2 safer-sk128 threeway serpent wake loki97
 rijndael-128 rijndael-192 rijndael-256 twofish blowfish-compat
 
 Supported modes:
 stream cbc cfb ecb ofb nofb
 
 Does someone know if I am coding something wrong or if there is a problem
 with the installation of php (v 4.0.6) on the server that I am on? Thanks
 for the help.
 
 --
 Dominic
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP and the Console

2001-08-20 Thread Andrew Libby


#!/path/to/php -q
?PHP

echo Hello World!\n;

?

On Mon, Aug 20, 2001 at 05:14:22PM +0100, Bill Brigden wrote:
 Hi all,
 
 How could I use a script on the console - to interact, and take the users
 input. Like a shell/perl script - but in php?
 
 Bill.
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Slow LDA Queries

2001-08-18 Thread Andrew Libby

Emilio,

Few thoughts:

o Is the call syntax you're using for ldap_read() correct?  The online
  manual page describes the second parameter as being the base dn, 
  you're passing the user's username. ( getenv(REMOTE_USER)).  I'm 
  surprised that this code works.  

o The comparisons you're making: Are they comparing similar LDAP searches.
  There are issues that may not involve PHP at all that could be the cause
  of you're performance issue.  For example, you're search could find all
  entries with a cn attribute at the base dn.  This could potentially be
  a large number of entries.  Also, if you search for something and the
  attributes you reference in your search filter are not indexed performance
  will degrade linearly as you add more entries to your directory.

o Session Caching.  At CommNav, we've had good success with this strategy.
  We store quite a bit of information in the users session.  It's not 
  uncommon for our user sessions to grow to above 100Kb, and I've seen
  them as big as 300Kb.   Retrieving data from the session (i.e. the
  unserialize() function) is much less expensive then going to LDAP for
  every hit to the web app.

 
Since these thoughts are not related to PHP, you can feel free to contact
me off-list to discuss further.   
  
Andy
  
  
On Sat, Aug 18, 2001 at 05:07:26PM -0400, Emilio Panighetti wrote:
 I have OpenLDAP and PHP 4.0.4p1 on a RedHat 7.1 (plain distribution, didn't
 recompile anything, and I use MOD_LDAP to authenticate users to an intranet
 site. I want PHP pages to show the real username so I have this function I
 call when I want to know the username.
 
 the mod_ldap queries and ldap queries from a Perl CGI return very fast. On
 Perl I don't notice an performance issue (with less than a couple
 queries/second), but each query using PHP takes about two full seconds (or
 more). I did a workaround keeping the result on a session variable, but it's
 still slow every time I call this function.
 mod_ldap stores the user's dn on the REMOTE_USER environment variable.
 
 Here's the function. I don't know how to make it faster.
 
 Thanks,
 Emilio Panighetti
 
 ?php
 // Retrieves user's real name from LDAP
 function ldapcnsearch()
 {
$s_ldapserver = localhost;
$s_ldapport = 389;
$ds = ldap_connect( ldap://.$s_ldapserver.:.$s_ldapport );
ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$qar[] = cn;
if ( $ds ) {
   $r = ldap_bind( $ds );
   $sr = ldap_read( $ds, getenv( REMOTE_USER ), cn=*, $qar, 0, 1,
 1 );
   $info = ldap_get_entries($ds, $sr);
   $s_RealName = $info[0][cn][0];
   ldap_close( $ds );
   return( $s_RealName );
}
 }
 ?
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySql or flat database using PHP ?

2001-08-18 Thread Andrew Libby


Dave,
IMHO, a major consideration for Web apps is contention and s
synchronization.  If you intend to allow users to update
data on in the app it becomes important to coordinate writes
(with locking) so that no two users can write to the same (region)
of the file at the same time.  An RDBMS (MySQL, PostgreSQL) or a directory
(OpenLDAP) takes care of this (as well as many other problems 
with data storage and retrieval).  I agree with the other statements I've
seen here, but wanted to add this as well.   I've done it both ways
and the DBMS, Directory route tends to be a better solution.   This is
code reuse of the best kind.

My humble $0.02.

Andy


On Sat, Aug 18, 2001 at 09:29:56PM +0100, David Ovens wrote:
 Before I start creating an Sql table/database, thought I would ask for advice first.
 
 I am creating a directory online, with urls information, links, email addresses etc 
etc.  What do you think is best a MySql database or writing it to a file using 
fopen/fwrite (flat file) ???  Your thoughts would be very much appreciated.
 
 
 Thanks
 
 Dave
 
 
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] class variables and methods

2001-08-18 Thread Andrew Libby

Joe,
There are varying opinions on this issue.  The argument for 
methods is that it hides the internal structure of your class.  This
is always a good thing.  This means that the internals of the class
can be changed, but the user interface (the user is the programmer here)
does not change.  So this alternative implementation of someclass


class someclass { 
var $data = false;

function set($key,$val) {
$this-data[$key] = $val;
}
}

is no different the the calling code.  In general, I tend to have an
accessor/mutator method for each 'property' that I would like to 
provide access to.  I'd have a method for each $key that I want to 
support (this may not apply in your case).

class someclass { 
var $name = false;
var $age  = false;

function name() { 
if(func_num_args()) $this-name = func_get_arg(0);
return $this-name;
}

function age() { 
if(func_num_args()) $this-age= func_get_arg(0);
return $this-age;
}
}

Now, this gets a big annoying to code since the lions share of my 
classes have the name method implementations.  I've been hunting
for a way to create methods dynamically, but I've only found one. 
To create class definitions on the fly and eval() them.  This 
works great when you've got a huge number of properties 
(class/instance vars).  I'll construct a static method on the 
class that processes examines the class vars (get_class_vars())
and defines a class extending my implementation.   The 
sub class has the methods implemented for accessing/mutating
the properties I'd like to have methods for.  If anyone knows
of a means to do this to an existing class (say using create_function()
or something), I'd love to hear about it.

Andy


On Sat, Aug 18, 2001 at 07:09:08PM -0700, Joe Sheble (Wizaerd) wrote:
 I've been doing some reading up on OOP in PHP, and looking at some of the
 classes available on the web, and I've got what is probably a stupid
 question.  I've seen this many many times..
 
 class someclass {
   var $somevar = someval;
 
   function set( $key, $val ) {
   $this-$key = $val;
   }
 }
 
 $myClass = new someclass;
 $myClass-set( somevar, someotherval );
 
 why write a set method when you can just as easily call
 $myClass-somevar = someotherval;
 
 Is there a reason for this?
 
 Also, alot of the different table classes (an OOP approach to HTML tables)
 stores the data in arrays, but at what point is it too much to store into an
 array?  Say you have a forum and the text entered for a single respone could
 be quite lengthy, much less for 100 replies...  wouldn't that be a bit much
 to store into an array?  I know it depends on the system resources, but is
 there a practical limit that people follow?
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Extract email address from string

2001-08-18 Thread Andrew Libby

Seb,

Seomthing like

?PHP
$string = Please send all email to [EMAIL PROTECTED] with a;

ereg('.* (.*@[^ ]* )',$string,$m);

echo $m[1] . \n


Might be a start.

Andy


On Sun, Aug 19, 2001 at 03:44:35AM +0100, Seb Frost wrote:
 Well you need to search for @
 
 then search forwards and backwards till you get to whitespaces
 
 store those positions
 
 then use the substr function.
 
 - seb
 
 -Original Message-
 From: Gaylen Fraley [mailto:[EMAIL PROTECTED]]
 Sent: 19 August 2001 03:37
 To: [EMAIL PROTECTED]
 Subject: [PHP] Extract email address from string
 
 
 I need to parse a string and extract only the email address.  What is the
 best way to do this?
 
 i.e.
 
 $string = Please send all email to [EMAIL PROTECTED] with a subject
 line of Test.;
 
 $email_addr would be equal to [EMAIL PROTECTED] .
 
 Thanks.
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Need Regex Help

2001-08-18 Thread Andrew Libby

I'd take the results of file() and then
walk through the array looking for the lines for the
various fruit you're concerned with.  Then I'd grab the next
two lines and process them, with something like:

$line = td align=left.46/td;

ereg('^td align=(left|right)([^]+)/td',$line,$m);

echo $m[1] . \n;
echo $m[2] . \n;

IMHO, it's bad to do this kind of thing because any change in
the content means a breakage of your processing code.  I
think that using something like XML or the DOM may be a
better approach.  Individuals with knowledge in this area can
speak more to this idea.

Good luck.

Andy


On Sat, Aug 18, 2001 at 09:48:11PM -0500, Craig Westerman wrote:
 I'm reading a book and have a little confusion in my mind.
 Consider the following table. Assume that I grabbed it from another web site
 using:
 ?
 $url = 'http://www.abc123xyz.com';
 $lines_array = file($url);
 $lines_string = implode('', $lines_array);
 ?
 
 ===
 
 htmlbody
 table cellspacing=2 cellpadding=2 border=0
 tr
 td align=centerbanana/td
 td align=left.46/td
 td align=right.55/td
 /tr
 tr
 td align=centerpear/td
 td align=left.38/td
 td align=right.51/td
 /tr
 tr
 td align=centerapple/td
 td align=left.59/td
 td align=right.33/td
 /tr
 /table
 /body/html
 
 ===
 
 The fruit lables don't change, but prices change daily.
 How would I parse JUST the two prices to the right of the word pear into a
 new html table?
 
 How would I parse the word pear AND the two prices to the right into a new
 html table?
 I think the answers will help me understand better.
 Thanks
 Craig 
 [EMAIL PROTECTED]
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
--
Andrew Libby
Director of Technology
CommNav, Inc
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]