Re: [PHP] Encryption failing

2008-01-17 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

(forgot to copy the list)

On Jan 16, 2008, at 5:08 PM, Richard Lynch wrote:



Is it possible that 4% of the time, you have spaces on the start/end
of the string, which get trimmed before encryption?



In this case, no. In trying to simplify the situation to narrow the  
possibilities of error, I am generating random character strings of  
only alphanumeric (or numeric-only) characters. Each is exactly 16  
characters.





And if rijndael is one of the algorithms which requires a fixed-size
input, that also would be bad to trim it.



No documentation that I was able to find suggests that requirement.





Actually, I'd suggest that the encryption function has no business
trimming the text anyway.



Philosophically I agree with you, but mCrypt has this nasty habit of  
appending bunches of nulls to the decrypted string. So philosophical  
purity gives way to practical application.


Good ideas, as usual. Thank you.

Ken


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encryption failing

2008-01-16 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jan 15, 2008, at 10:48 PM, Casey wrote:


It returns the correct value. If you look at the last example, and run
base64_decode on MDAwMzEwMDI0NDA0MTMyOQ==, you will get
0003100244041329.


Oops. Haste makes crappy programming.

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encryption failing

2008-01-16 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jan 16, 2008, at 1:28 AM, Andrés Robinet wrote:


1 - Mike is right about first encrypting and then doing a  
base64_encode (then saving results to DB, cookies, etc). I don't  
know why replacing   to + for decrypting, though.




His other post explains that php didn't seem to like spaces. No  
spaces in the test strings -- I'll check for those when/if I can get  
the core en/decryption working.



2 - Mike is also right about $text = base64_decode($text) which  
should be $text = base64_decode($text_out) I think.




Yup -- that's what i get for trying to do this hastily and late at  
night --



3 - You are trimming the results on return, according to one post  
in the manual notes this will remove null padding on the decrypted  
string. This is desired, most of the time, but if the original  
(cleartext message) string ended in nulls you will get a difference  
and that may be the cause of the errors you are getting.




I understand that, thank you. There are no trailing nulls on the  
original string.


After correcting the my program, I still get the same results, about  
4% wrong:


70: String: 5214006139804600
 -|- Enc: Ϊ%bÇCsšBsìD%Å#z[ä. m…‡¿m§ð
 -|- Dec:àc8 -|- Nope

75: String: 1034702254251899
 -|- Enc: !:Ã2ºÍé×»àe2s? :Ù0LµŒÕ[«
 -|- Dec:à`*' -|- Nope

89: String: 8245007043826594
 -|- Enc: µÆ Íãd-‘Á´E3½yÍ×v‹,ZØWéûqüŽ‚ó
 -|- Dec:[EMAIL PROTECTED] -|- Nope

etc.

Wrong: 23/500


Phooey.

Ken
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encryption failing

2008-01-16 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Many thanks, Mike --- yours works great... 0 errors.

On Jan 16, 2008, at 9:24 AM, mike wrote:


function data_encrypt($data) {
if(!$data) { return false; }
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256,
$GLOBALS['config']['salt'], $data, 'cbc', md5($GLOBALS['config']['
salt'].$GLOBALS['config']['salt'])));
}

function data_decrypt($data) {
if(!$data) { return false; }
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,
$GLOBALS['config']['salt'], base64_decode(str_replace(' ', '+',
$data)), '
cbc', md5($GLOBALS['config']['salt'].$GLOBALS['config']['salt'])));
}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Encryption failing

2008-01-15 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Hey --- - -

I am in the process of upgrading the encryption technology I am using  
from (64 bit) blowfish to (256 bit) rijndael.


The code (and some explanations) is below, but the results are, um,  
unusual, and I can't see what I am doing wrong. For testing, I have a  
program that generates a random 16-character string, encrypts it to a  
variable, and decrypts it. Running it in 500 iteration loops, it  
fails roughly 4% of the time. By fails I mean that the original  
string and the eventual decrypted one don't match.


Anybody able to spot why?

Ken
--
function jagencdecr($text,$EorD,$encpass='') {
// parameters:
// - $text = string to be en/decrypted,
// - $EorD = Encrypt or Decrypt
// - $encpass = key phrase
if (empty($text)) {return ;}
$text = trim($text);
$cypher = mcrypt_module_open('rijndael-256', '', 'ecb', '');
// ecb mode produces the above results.
// ofb mode produces 100% errors

$size = mcrypt_enc_get_iv_size($cypher);
$phprand = rand(1000,);
	$iv = mcrypt_create_iv($size,$phprand); // produces the same results  
as below, platform independent

//$iv = mcrypt_create_iv($size,MCRYPT_RAND); // for Windows
//$iv = mcrypt_create_iv($size,MCRYPT_DEV_RAND); // for 'NIX

$ks = mcrypt_enc_get_key_size($cypher);
/* Create key */
$key = substr(md5($encpass), 0, $ks);
mcrypt_generic_init($cypher,$key,$iv);
if ($EorD == D) {
$text_out = mdecrypt_generic($cypher,$text);
} else {
$text_out = mcrypt_generic($cypher,$text);
} // endif ($EorD == D)
mcrypt_generic_deinit($cypher);
mcrypt_module_close($cypher);
return trim($text_out);

}  // endfunc jagencdecr Jaguar Ecnrypt/Decrypt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encryption failing

2008-01-15 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jan 15, 2008, at 7:06 PM, Casey wrote:


Maybe you could echo the results of the failed ones and compare.


I did that at first, thinking that something about these strings  
might cause the problem. But then I realized: I can't blame the  
data. I don't have any control over what users use for passwords, for  
example. this thing is supposed to en/decrypt the strings I gige it,  
so there must be some kind of programming flaw.


FWIW, there was no discernible pattern to the failed strings, at  
least not to me. (Not that it matters.)


Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encryption failing

2008-01-15 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jan 15, 2008, at 11:08 PM, Andrés Robinet wrote:


-Original Message-
From: Bastien Koert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 16, 2008 12:55 AM
To: Ken Kixmoeller -- reply to [EMAIL PROTECTED]; php-
[EMAIL PROTECTED]
Subject: RE: [PHP] Encryption failing


are you base64 encoding the resultant encryption string? I have found
that there are problems with certain characters that can result from
the encryption, usually a combination of characters that  
approximate a

null or end of line

bastien From: [EMAIL PROTECTED] Date: Tue, 15 Jan 2008  
21:41:45 -

0600 To: php-general@lists.php.net Subject: Re: [PHP] Encryption
failing   On Jan 15, 2008, at 7:06 PM, Casey wrote:   Maybe  
you
could echo the results of the failed ones and compare.  I did  
that at

first, thinking that something about these strings  might cause the
problem. But then I realized: I can't blame the  data. I don't have
any control over what users use for passwords, for  example. this
thing is supposed to en/decrypt the strings I gige it,  so there  
must

be some kind of programming flaw.  FWIW, there was no discernible
pattern to the failed strings, at  least not to me. (Not that it
matters.)  Ken  --  PHP General Mailing List
(http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


I second that, you should base64 encode values before encrypting  
and base64

decode them after decrypting to be safe.

Rob

Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale,  
FL 33308

| TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE:
bestplace |  Web: http://www.bestplace.biz | Web: http://www.seo- 
diy.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Encryption failing

2008-01-15 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jan 15, 2008, at 11:08 PM, Andrés Robinet wrote:


I second that, you should base64 encode values before encrypting  
and base64

decode them after decrypting to be safe.



Thanks for the idea.

Like this? Fails 500/500 times on my test.


if ($EorD == D) {
$text_out = mdecrypt_generic($cypher,$text);
$text = base64_decode($text);
} else {
$text= base64_encode($text);
$text_out = mcrypt_generic($cypher,$text);
} // endif ($EorD == D)


A quick test looks like this:

1: String: 9334133814260182
 -|- Enc: X5Þ©·ža`p#È]#c¦±3ÔýCõÒiÏ~r¢Tª
 -|- Dec:OTMzNDEzMzgxNDI2MDE4Mg== -|- Nope

2: String: 3027022406512648
 -|- Enc: j£n,h\mê´ uKP%¥†¼D}H‚’f¢š„
 -|- Dec:MzAyNzAyMjQwNjUxMjY0OA== -|- Nope

3: String: 5042504153020331
 -|- Enc: 9ÿ•ýŸÝ§¤6Wi+€×Ÿéáonñº*J6}Ø+„
 -|- Dec:NTA0MjUwNDE1MzAyMDMzMQ== -|- Nope

4: String: 6741156238850410
 -|- Enc: ·:´[Úq\‹ë‹4\Q«ÍŽ5±{º‡µØtþðtN?b
 -|- Dec:Njc0MTE1NjIzODg1MDQxMA== -|- Nope

5: String: 0003100244041329
 -|- Enc: D¾¤úV:!Mû4ƒÜ€àœ‰ŽòÐÐ^ïHñ-š%z
 -|- Dec:MDAwMzEwMDI0NDA0MTMyOQ== -|- Nope

Wrong: 5/5

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generating foldout menus in php

2007-09-06 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Sep 3, 2007, at 12:42 PM, tedd wrote:



that would be more complicated than just using css with js, like so:

http://sperling.com/examples/menuh/

http://sperling.com/examples/menuv/

Why complicate your life?



Hey, tedd - - - -

I like this tool, and am playing with it -- --

Just wondering, though, if you have ever created PHP code to generate  
these menus on-the-fly? I am working on an intranet application in  
which I take values from rights-and-responsibilities tables and use  
it to generate navigation options. Got a start on it, but if you  
already had some code I'd appreciate getting a gander at it.


KixJaguar - -

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generating foldout menus in php

2007-09-06 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Sep 6, 2007, at 11:02 AM, Edward Kay wrote:


You may want to take a look at Yahoo's YUI menu:
http://developer.yahoo.com/yui/menu/

These can be defined using standard XHTML markup.


Thank you --- I will do that --

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generating foldout menus in php

2007-09-06 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Sep 6, 2007, at 10:47 AM, Ken Kixmoeller -- reply to  
[EMAIL PROTECTED] wrote:


Just wondering, though, if you have ever created PHP code to  
generate these menus on-the-fly?


Never mind === I got it working. (Mechanically) --

Aesthetically, though, even though I used the horizontal classes,  
it comes out vertical -- any clues?


thanks ---

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generating foldout menus in php

2007-09-06 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Sep 6, 2007, at 1:17 PM, Ken Kixmoeller -- reply to  
[EMAIL PROTECTED] wrote:


Aesthetically, though, even though I used the horizontal classes,  
it comes out vertical


Never mind (not that you did) -- got it working fine ---

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Removing a row from an Array

2007-06-08 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jun 5, 2007, at 5:20 PM, Richard Lynch wrote:


am I missing something (other than a few brain cells)?


http://php.net/unset

As in, unset($array['goner']);


Yup, that's the one. Thanks to you, too.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Removing a row from an Array

2007-06-04 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Hey - - - - - - --

To do this, I am:

 - looping through the array
 - copying the rows that I want to *keep* to a temp array, and
 - replacing the original array with the temp' one.

Seems convoluted, but I couldn't find any function to remove a row of  
an array. Am I missing something (other than a few brain cells)?


thanks - - -

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Removing a row from an Array

2007-06-04 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jun 4, 2007, at 2:25 PM, Jay Blanchard wrote:


http://us2.php.net/manual/en/function.array-pop.php


Thanks, Jay ---

I did see that function, but forgot about it when I asked the  
question. I should have added that *any* array row among many could  
be the one that needs to be removed. I couldn't figure out how to  
reorder the array so that POP would work.


Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Removing a row from an Array

2007-06-04 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jun 4, 2007, at 3:29 PM, Peter Lauri wrote:



You could use unset() for the rows you don't want to keep.



Ah --- yes, that looks like it would do it. I was expecting something  
to find something array-specific.


Thank you, Pater and Roberto

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Removing a row from an Array

2007-06-04 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

On Jun 4, 2007, at 3:27 PM, Al wrote:



What determines the rows you want to keep?



User selection. The array is essentially a shopping cart-type of  
object.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Capture the whole URL

2007-02-23 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Feb 22, 2007, at 10:26 PM, tedd wrote:



Print out these three and you'll see your problem.

$_SERVER['SERVER_NAME']
$_SERVER['QUERY_STRING']
$_SERVER['REQUEST_URI']



Thanks, Tedd - -

REQUEST_URI still generates a Undefined Index error
SERVER_NAME on my testing server returns its IP

***QUERY_STRING***  is the one I wanted.

I didn't see it (but then again, I am working through the worst head  
cold I have had in years. My head is a solid block. Watta pain.)


Many thanks.

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Capture the whole URL

2007-02-23 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Feb 23, 2007, at 12:18 AM, Jim Lucas wrote:



  diddly.com?id=fredtotal=goof

First of forgoing the http:// missing, this still isn't a qualified  
URL




Yeah, I was just giving an example of what I wanted.




echo $_SERVER['REQUEST_URI'];
and see what it returns



I said in the post, it returns an error: Undefined index. I wonder  
if this doesn't work on a Wintel server? Is it supposed to return the  
whole thing?




if for some odd reason that doesn't work try: echo $_SERVER 
['QUERY_STRING'];




Yes, thanks, that gave me what I wanted, or at least it will together  
with 'PHP_SELF' that part of the URL that I wasn't getting otherwise.





show us an example of the script that generates the error



I was testing just with simple echo statements.



Looks like you either typed this pretty fast or maybe you had a few  
typo's.  Review your code and check that you are using underscores  
and not hyphens.




Yes, sorry -- I was both in a hurry (wife gently beckoning me to  
get moving) and drugged up. My code was syntacticly correct.


Thank you for your help, Jim.

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Capture the whole URL

2007-02-23 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Feb 22, 2007, at 4:33 PM, Jochem Maas wrote:


do a var_dump($_SERVER); or phpinfo(); to see what you do have  
available.




'REQUEST_URI' doesn't show. Now I see the line in the documentation  
that says You may or may not find any of the following elements...


How do I find out whether QUERY_STRING will work on the working  
server? I'll do some searching, but is anyone aware of a resource  
that tells which server hardware/software supports which ones?


H... it might be smarter to use the $_GET's to recreate the  
string if these things are inconsistent.


Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Capture the whole URL

2007-02-23 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Feb 23, 2007, at 7:46 AM, tedd wrote:


On Feb 22, 2007, at 10:26 PM, tedd wrote:


Print out these three and you'll see your problem.

$_SERVER['SERVER_NAME']
$_SERVER['QUERY_STRING']
$_SERVER['REQUEST_URI']


Thanks, Tedd - -

REQUEST_URI still generates a Undefined Index error
SERVER_NAME on my testing server returns its IP

***QUERY_STRING***  is the one I wanted.

I didn't see it (but then again, I am working through the worst  
head cold I have had in years. My head is a solid block. Watta pain.)


Many thanks.

Ken


Ken:

As per my understanding, the $_SERVER['REQUEST_URI'] should give  
you something -- after all, it's from where the request came from  
(i.e., your app).


In your code, simply do a print_r($_SERVER) and see what happens.


I did this (actually a var_dump) and $_SERVER['REQUEST_URI'] doesn't  
show up at all. See my message replying to Jochem.


Thanks for your code. I'll check it out.

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Capture the whole URL

2007-02-22 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Hey - -

I must be missing something, but in a URL such as:

  diddly.com?id=fredtotal=goof

$_SERVER['PHP-SELF'] gives me the diddley.com part.

I want to capture the whole URL. The documentation makes it seem like  
$_SERVER['REQUEST_URI'] is supposed to do that, but I get an  
Undefined Index error.


Do I have to enable this somehow? I realize that I could recreate the  
rest of the URL from $_GET's, but I'd rather not if I don't have to.


PHP 5.1

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Sessions working/not

2007-02-07 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Hey - -- -

Would anyone be so kind as to un-stick my brain?

I can't get sessions to work on my development machine (localhost).  
They work fine on my testing server (an internal IP). Development:  
W2K, Testing Server W2K Server, both using IIS 5, PHP 5.2.


The php.ini SESSION settings are the same on both machines.

Seems to me I made this choice at some point, but now my feeble brain  
can't bring it up.


bueller
Anyone? Anyone?
/bueller

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Executing scripts from a table

2007-02-03 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Feb 2, 2007, at 6:59 PM, Richard Lynch wrote:


Putting PHP source into MySQL is the WRONG way to go for security and
efficiency...


Thank you, Richard -- I appreciate your advice.

Here is a qualifier: I'm not putting any core code into tables, just  
code which generates page content. The access rights to that page  
content, as well as security code and application objects are not  
there. That code is off of the web path, called by functions. No SQL  
is in tables. So maybe I shouldn't have said security.


With that in mind -- I would really appreciate it if would help me  
understand your comment or point me to a resource which will. I have  
read a bunch of stuff on security, but no resources led me to believe  
that I was on a wrong path, though none of them followed the path I  
am on. It isn't too late for me to change.


Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Executing scripts from a table

2007-02-03 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Feb 3, 2007, at 9:32 AM, Ken Kixmoeller -- reply to  
[EMAIL PROTECTED] wrote:


I'm not putting any core code into tables, just code which  
generates page content. The access rights to that page content, as  
well as security code and application objects are not there. That  
code is off of the web path, called by functions. No SQL is in  
tables. So maybe I shouldn't have said security.


I should add: All of the PHP in the tables is making calls to UI  
objects and data objects (which contain the SQL). Those classes are  
also off of the web tree. My goal has been to locate any and all page- 
related content (HTML and PHP) in a single location.


I am *not* trying to justify my strategy here. I just want to provide  
enough information to anybody willing to help me understand if it is  
ill-conceived.


Thank you,

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can a class instance a property of another class

2007-02-02 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]
Thanks to all -- got all of this working fine. Mostly my syntax was a  
bit off. Your examples helped me mend my ways.


Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Executing scripts from a table

2007-02-02 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Hi, folks -- - -

For security and efficiency, I am trying to store PHP scripts in  
MySQL tables. Only problem: I can't get them to execute.


In a template:

$php_code = $this-ApplicationObject-GetStoredCode($whichpage);

echo $php_code;  // doesn't execute

print_r($php_code); // doesn't execute, either


I've looked for some kind of exec_script() function without luck.

I can't be the first one to have done this. Any ideas or resources  
you can point me to?


Thank you -- - -

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Executing scripts from a table

2007-02-02 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Yeah, that was it. Thanks, Thomas.

(dang it, I should have been able to figure out that myself!)

Ken


On Feb 2, 2007, at 11:32 AM, Thomas Pedoussaut wrote:


Ken Kixmoeller -- reply to [EMAIL PROTECTED] wrote:

Hi, folks -- - -

For security and efficiency, I am trying to store PHP scripts in  
MySQL tables. Only problem: I can't get them to execute.


In a template:

$php_code = $this-ApplicationObject-GetStoredCode($whichpage);

echo $php_code;  // doesn't execute

print_r($php_code); // doesn't execute, either



I think you're thinking of eval()
http://ie2.php.net/manual/en/function.eval.php

It should do what you want.

--
Thomas




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can a class instance a property of another class

2007-01-27 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]
Thanks for your help, guys. I had to leave my office last evening  
before I had a chance to try any of them.


I am sneaking in some office time today. I'll let you know (with  
complete scripts and error messages).


Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can a class instance a property of another class

2007-01-27 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]
OK, Jochem, I adapted your example and got it working. Thank you very  
much.


I am still playing with it to better understand. One thing I don't  
yet understand is the necessity for the getFoo()/getBar()  
handshake, especially the getbar() in the BAR class. That doesn't  
seem to serve any purpose. My adaptation us just a getDummy().


Do they just serve to pass the object by reference?


Ken

--
On Jan 26, 2007, at 5:47 PM, Jochem Maas wrote:




class Foo
{
private $var;
function __construct() { $this-var = foo; }
function getFoo() { return $this-var; }
}

class Bar
{
private $var;
private $foo;
function __construct() { $this-var = bar; $this-foo = new Foo; }
function getBar() { return $this-var; }
	function speak() { echo I am ,$this-foo-getFoo(),$this-getBar 
(),\n; }

}




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Creating an array as a property of an object

2007-01-26 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Hello, folks -- lurking for a while, first post --

I'm relatively new to PHP but doing database design work for nearly  
20 years.


I've RTFM'ed (+ books + other resources) a bunch of times but I have  
a mental block around doing this:


I want to have an multidimensional array as a property of an object.

Example:

MySQL Resource:
 WHAM_ID  NAME AMOUNT
  5   Fred 99
  9   Albert  345
 23   Mary  5
 (etc...)

Inside the function which builds the instance of the object, I have  
language like:


while ($line = mysql_fetch_array($result_set,MYSQL_ASSOC))
{
  $this-foom_array = array(MyKey.$line[wham_id]=array($line).,;
}
This isn't even close. g

Any examples, or a well-written resource to help me do this?

TIA

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating an array as a property of an object

2007-01-26 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]


On Jan 26, 2007, at 3:08 PM, Robert Cummings wrote:


$this-foom_array[$line['WHAM_ID']] = $line;

Cheers,
Rob.


Thank you so much, Rob. That did it. (Kickin' the cobwebs out of my  
head...)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Can a class instance a property of another class

2007-01-26 Thread Ken Kixmoeller -- reply to [EMAIL PROTECTED]

Hey - --  -

Here I am again. Anybody still working on a Friday?

I would like to have a class instance be the property of another  
class, like can be done in other languages. For example: I would like  
to have a Connections class which contains all of the database  
connection logic and query results. There are advantages to having  
this type of utility class be local to a data or business class. (I  
know that I could have a generic include with functions outside of  
the class hierarchy.)


So, in the __construct method of a business or data class, for  
example, one could:


include_once(connection_classes.kbk);
$this-connection_class = new connection_class;

This syntax fails, so I know this isn't right, but I hope you get the  
idea.


Can it be done?

TIA, again

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php