Re: [PHP] Month with leading zeros
On 5/10/08, Ron Piggott [EMAIL PROTECTED] wrote: I am wanting to change echo option value=\ . $months[$month] . \; to output the month number, between 01 and 12 --- DATE value m, the month with leading 0's. How do I do this? $months is an array, as I have shown below. Ron ?php $months = array('1' = 'January', '2' = 'February', '3' = 'March', '4' = 'April', '5' = 'May', '6' = 'June', '7' = 'July', '8' = 'August', '9' = 'September', '10' = 'October', '11' = 'November', '12' = 'December'); $current_month = DATE(n); echo SELECT NAME=\order_received_month\\r\n; foreach ($months as $i = $month) { echo option value=\ . $month . \; if ( $i == $current_month ) { echo SELECTED;} echo . $month . /option\r\n; } ? /select -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Complex escape string
On 5/3/08, cyaugin [EMAIL PROTECTED] wrote: I have this line of code: $q = This is the string that will go into the query: {${mysql_real_escape_string($_GET['searchstring'])}}; What happens then is the user supplies 'foo' as the search string, and I get a debug notice Undefined variable: foo. Why is it treating the value as an identifier and how do I make it do what I actually want it to do? This is on PHP5, latest release. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $q = This is the string that will go into the query: . mysql_real_escape_string($_GET['searchstring']); -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new $foo-className(); Class name must be a valid object or a string
On May 3, 2008, at 4:46 PM, Jack Bates [EMAIL PROTECTED] wrote: I am trying to load PHP objects stored in a database, where the class name is stored in a column: $object = new $resultSet-getString(1); This fails for the same reason that the following fails: ?php class Foo { public function className() { return 'Foo'; } } $foo = new Foo; $bar = new $foo-className(); Fatal error: Class name must be a valid object or a string in test.php on line 12 I guess this error is due to the confusion of parsing () as the argument list for the className function, or the Foo constructor... I work around this error by using a temp variable: $tmp = $foo-className(); $bar = new $tmp; - however the above reads like hacky code : ( When calling dynamically named functions, I generally use call_user_func() to avoid awkwardness with $object-$tmp($arg1, ...) In other words, I prefer: call_user_func(array($object, 'get'.$someName), $arg1, ...); - to: $tmp = 'get'.$someName; $object-$tmp($arg1, ...); However there does not appear to be an analog of call_user_func() for constructing new instances of dynamically named classes? If I recall correctly, there was also a way to work around calling dynamically named functions (e.g. $object-$tmp($arg1, ...);) using curly braces: $object-{'get'.$someName}($arg1, ...); - however I cannot recall the exact syntax. Can anyone confirm that there is a curly brace syntax for calling dynamically named functions? Could it be applied to instantiating dynamically named classes? Can anyone recommend a cleaner alternative to: $tmp = $foo-className(); $bar = new $tmp; Thanks and best wishes, Jack Does... ?php $bar = new $foo-className()(); ? ...work? Otherwise, I'd just do... ?php $className = $foo-className(); $bar = new $className; ? ...instead of $tmp. -- 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] Execute command from web browser
On 5/3/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all I try write a code to execute service in my server from web browser I write next /var/www/html/squidup.html Should it be... squidup.php? ? exec ('/usr/bin/squid/sbin/squid') echo Squid UP ? but, don't work from web browser. What is wrong Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach loop to set variables
On Apr 25, 2008, at 6:12 AM, jamest [EMAIL PROTECTED] wrote: I am passing an array to a class which I want to take the array data and create some variables from the array's keys and values. So I want to create (in this case 21) new variables that I want to create in the foreach but with no success. foreach ($formdata as $key = $value) { echo $key = $value; } This echo's all the data how I would expect. But taking the echo out to have: foreach ($formdata as $key = $value) { $key = $value; } But this doesn't work. The variables aren't set. I was thinking that I could set up the variables outside of the function by using public $variablename for all the different variables then set the variable value using: foreach ($formdata as $key = $value) { $this-key = $value; } But that didn't work either. -- View this message in context: http://www.nabble.com/foreach-loop-to-set-variables-tp16895552p16895552.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php foreach ($formdata as $key = $value) $formdata[$key] = $value; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] loop inside a loop
On Thu, Apr 17, 2008 at 6:51 PM, Alan Willsher [EMAIL PROTECTED] wrote: Hi can you put a loop inside a loop? what I want to do is have something looping every 1 second and then something else looping once every 10 seconds. something like a combination of these two.. $x = 0; while ($x 1000) { echo 1; $x++; sleep(1); } $y = 0; while ($y 100) { echo 2; $y++; sleep(10); } but at the same time so it would output something like 11211211212 Thanks ?php $x = 0; while ($x 1000) { echo 1; $x++; if ($x % 10 == 9) echo 2; sleep(1); } ? :) -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Serialization Performance
On Wed, Apr 16, 2008 at 4:04 AM, Waynn Lue [EMAIL PROTECTED] wrote: I'm using PHP to cache files that are backed by the database. In the course of writing these functions, I end up with a set of variables that are needed by my application, returned in an array. I can either directly generate the array in a .php file, then use require_once to get that variable, or I can use PHP serialization, write that array out to a file, then in my application read the array in, deserialize, etc. I spent awhile trying to look at the performance of php serialization, but except for one unsubstantiated comment on the php serialize() doc page, I haven't found much. Does anyone have any knowledge of that, and also of the two approaches in general? The pro of the serialization is that I think it's slightly easier to write, but the con is that it's harder to read. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php According to this (http://us2.php.net/manual/en/function.var-export.php#76099), serialize is faster than var_export. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return an Array and immediately reference an index
On Sat, Apr 12, 2008 at 9:12 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Fri, Apr 11, 2008 at 6:33 PM, Daniel Kolbo [EMAIL PROTECTED] wrote: search the archives ;) http://www.mail-archive.com/php-general@lists.php.net/msg224626.html -nathan ?php function ReturnArray() { return array('a' = 'f', 'b' = 'g', 'c' = 'h', 'd' = 'i', 'e' = 'j'); } echo ${!${!1}=ReturnArray()}['a']; // 'f' ? :) -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return an Array and immediately reference an index
On Sat, Apr 12, 2008 at 9:35 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sat, Apr 12, 2008 at 12:18 PM, Casey [EMAIL PROTECTED] wrote: On Sat, Apr 12, 2008 at 9:12 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Fri, Apr 11, 2008 at 6:33 PM, Daniel Kolbo [EMAIL PROTECTED] wrote: search the archives ;) http://www.mail-archive.com/php-general@lists.php.net/msg224626.html -nathan ?php function ReturnArray() { return array('a' = 'f', 'b' = 'g', 'c' = 'h', 'd' = 'i', 'e' = 'j'); } echo ${!${!1}=ReturnArray()}['a']; // 'f' ? ya; i never did sit down and try to figure out how that works; care to explain ? -nathan ?php echo ${!${!1}=ReturnArray()}['a']; ${!${!1}=ReturnArray()}['a'] !1 resolves to false. ${!${false}=ReturnArray()}['a'] false resolves to... I don't know. Let's just say false resolves to a. ${!$a=ReturnArray()}['a'] $a is now the array. The ! changes the returned array into the boolean false (like: if (!$handle = fopen('x', 'r')) { echo 'connection failed' }. ${false}['a'] I don't know what false resolves to, but we're using a. $a['a'] ? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a simple one time search utility
On Apr 12, 2008, at 12:13 PM, Al [EMAIL PROTECTED] wrote: I need a simple utility that simulates GREP to find a certain string in any php files on my website. Site is on a shared host w/o shell access so I can't run GREP. I can write a PHP scrip to do it; but, this is a one time thing and I was hoping to find something to save me the effort. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ?php shell_exec('grep ...'); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quarters
On Fri, Apr 11, 2008 at 6:49 AM, tedd [EMAIL PROTECTED] wrote: Hi gang: Check out my new game: http://webbytedd.com/quarters/ What do you think? Cheers, tedd PS: I originally wrote the game for the Mac over eight years ago. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I won. Finally figured out the secret, without $5 _ -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] require_once dying silently
On Tue, Apr 8, 2008 at 8:27 PM, Greg Bowser [EMAIL PROTECTED] wrote: ?php echo 'begin brainstorm.'; ? Is it possible that something is going wrong between the definition of $CFG-foo and when you require that could cause $CFG-dirroot to be null? Then it would point to /lib/setup.php, which definitely shouldn't exist and should thus throw an error, but maybe it's worth looking into. ?php require_once('Have you tried including a file that definitely does not exist?'); ? That would rule out any error reporting problems anyway. Have you tried something to the effect of ?php echo __FILE__ . ' included'; ? on the first line of setup.php? Adding ?php print_r(get_included_files()); ? after the require_once() might also help. I've confirmed that the file setup.php exists and is readable. I apologize if this seems obvious, but for the sake of brainstorming... it's readable by the user running apache, right? And even if it weren't, that should have thrown an error *shrugs* That's all I can think of. I hope it is of some use to you. ?php echo 'end brainstorm.'; ? ?php signature('GREG'); ? You should try: ?php require_once(/home/rcrawford/public_html/tanktrunk/tanktrunk/lib/setup.php); ? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] books for php
On Tue, Apr 8, 2008 at 10:29 AM, Daniel Brown [EMAIL PROTECTED] wrote: On Tue, Apr 8, 2008 at 1:26 PM, Jason Pruim [EMAIL PROTECTED] wrote: You mean that books are supposed to have stuff other then pictures? Well hot damn Learn something new everyday! Some programming books, such as guides to Windows source code, have pictures. http://www.pilotpig.net/images/winsource.jpg ROFL. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include fails when ./ is in front of file name
On Sun, Apr 6, 2008 at 2:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED] wrote: This works: include(file.inc.php); This doesn't: include(./file.inc.php); I can't figure it out! PHPMyAdmin uses ./ so it's obviously not working. Here's my environment: Win2003 Server w/ IIS 6 PHP 5.2.5 setup as ISAPI All PHP and httpdoc directories have read, write, and execute permissions given to IIS_WPG, IIS_USER, and NETWORK SERVICE PHP.ini's include path is: include_path = .;.\includes;.\pear (I've also tried include_path = .;./includes;./pear) phpinfo() works fine. Anyone have any ideas? Thanks! Noah Is that include() statement being issued within an included PHP page? a.php ?php include('directory/b.php'); ? directory/b.php ?php include('./c.php'); // Does this refer to c.php or directory/c.php ? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Arbitrary mathematical relations, not just hashes
On Sun, Apr 6, 2008 at 4:52 PM, Kelly Jones [EMAIL PROTECTED] wrote: Many programming languages (including Perl, Ruby, and PHP) support hashes: $color['apple'] = 'red'; $color['ruby'] = 'red'; $type['apple'] = 'fruit'; $type['ruby'] = 'gem'; This quickly lets me find the color or type of a given item. In this sense, color() and type() are like mathematical functions. However, I can't easily find all items whose $color is 'red', nor all items whose $type is 'fruit'. In other words, color() and type() aren't full mathematical relations. Of course, I could create the inverse function as I go along: $inverse_color['red'] = ['apple', 'ruby']; # uglyish, assigning list to value and there are many other ways to do this, but they all seem kludgey. Is there a clean way to add 'relation' support to Perl, Ruby, or PHP? Is there a language that handles mathematical relations naturally/natively? I realize SQL does all this and more, but that seems like overkill for something this simple? -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile. Something like this? ?php $objects = array( 'apple' = array( 'type' = 'fruit', 'color' = 'red' ), 'ruby' = array( 'type' = 'gem', 'color' = 'red' ) ); // Search for all red objects. $red = array(); foreach ($objects as $name = $object) { if ($object['type'] == 'red') $red[] = $name; } ? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Arbitrary mathematical relations, not just hashes
On Sun, Apr 6, 2008 at 4:52 PM, Kelly Jones [EMAIL PROTECTED] wrote: Many programming languages (including Perl, Ruby, and PHP) support hashes: $color['apple'] = 'red'; $color['ruby'] = 'red'; $type['apple'] = 'fruit'; $type['ruby'] = 'gem'; This quickly lets me find the color or type of a given item. In this sense, color() and type() are like mathematical functions. However, I can't easily find all items whose $color is 'red', nor all items whose $type is 'fruit'. In other words, color() and type() aren't full mathematical relations. Of course, I could create the inverse function as I go along: $inverse_color['red'] = ['apple', 'ruby']; # uglyish, assigning list to value and there are many other ways to do this, but they all seem kludgey. Is there a clean way to add 'relation' support to Perl, Ruby, or PHP? Is there a language that handles mathematical relations naturally/natively? I realize SQL does all this and more, but that seems like overkill for something this simple? -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I hit reply-all... now am I suddenly subscribed to Perl and Ruby lists!?! -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PostTrack Updates
On Apr 5, 2008, at 6:23 AM, Jason Pruim [EMAIL PROTECTED] wrote: On Apr 5, 2008, at 1:48 AM, Robert Cummings wrote: On Fri, 2008-04-04 at 22:39 -0700, Jim Lucas wrote: Robert Cummings wrote: ?php echo On Fri, 2008-04-04 at 17:23 -0400, Daniel Brown wrote: \n ? ?php echo Some changes take effect with the PostTrack metrics \n ? ?php echo system with this week (will show up in next week's \n ? ?php echo report). There's one bug fix and a new feature added, \n ? ?php echo in which some of you may be really interested.\n ? ?php echo \n ? ?php echo CHANGELOG\n ? ?php echo \n ? ?php echo Fixed a bug that would (seemingly random) \n ? ?php echo split a user's post recording over multiple entries. \n ? ?php echo (See this week's report: Zoltan Nemeth for example) \n ? ?php echo Added a new CodeCount feature. Explained \n ? ?php echo below.\n ? ?php echo \n ? ?php echo The CodeCount feature will, from now on, track \n ? ?php echo the amount of [pseudo]code everyone posts to the \n ? ?php echo list. However, for a variety of reasons (including \n ? ?php echo enforcing Good Coding Practices[tm], there will be \n ? ?php echo some rules:\n ? ?php echo \n ? ?php echo * short_open_tags code will not be counted. \n ? ?php echoIt must begin with ?php, not ?, and\n ? ?php echo?=\$variable;? things won't count.\n ? ?php echo * All code must be properly closed as well as \n ? ?php echoopened. Thus, ?php must be followed by ?.\n ? ?php echo * You can include multiple blocks of code, \n ? ?php echoand all will be tallied. So:\n ? ?php echo ?php\n ? ?php echo // Block one\n ? ?php echo ?\n ? ?php echo and \n ? ?php echo ?php\n ? ?php echo // Block two\n ? ?php echo ?\n ? ?php echo will both be counted.\n ? ?php echo \n ? ?php echo Some notes that should be obvious:\n ? ?php echo * HTML won't be counted unless included in an \n ? ?php echoecho/print construct or a HEREDOC/NOWDOC \n ? ?php echo(when used). Only the code between the \n ? ?php echo?php and ? tags will be counted.\n ? ?php echo * The CodeCount procedure *does* count\n ? ?php echocomments as code. This can be changed if \n ? ?php echothere's enough desire.\n ? ?php echo * CodeCount *will not* differentiate between \n ? ?php echo\Good\ and \Bad\ code. If you forget a \n ? ?php echosemicolon, it'll still count.\n ? ?php echo \n ? ?php echo --\n ? ?php echo /Daniel P. Brown\n ? ?php echo Ask me about:\n ? ?php echo Dedicated servers starting @ \$59.99/mo., VPS\n ? ?php echo starting @ \$19.99/mo., and shared hosting starting @ \n ? ?php echo \$2.50/mo. Unmanaged, managed, and fully-managed! \n ? I don't know about anyone else, but I am absolutely stoked about this development! Cheers, Rob. wait you forgot the semi-colon... ah, that's right, he said grammar mistakes were not counted... Perfectly valid to omit the last semi-colon when closing a PHP block. ?PHP echo 'So does the new code count all quoted code as well? :)';? ?PHP echo 'If so... Then we are going to have a ton of code to start with!';? :) ;) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- 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 Does it count if I quote it! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: array with null shows different with print_r and var_dump
On Tue, Apr 1, 2008 at 11:49 PM, Sanjay Mantoor [EMAIL PROTECTED] wrote: Hello, I am new to PHP and PHP community. Following program outputs different values with print_r and var_dump. $array = array(null, NULL); print_r($array); prints values like below Array ( [0] = [1] = ) print_r converts null, which is a variable type, like integer, string, float, etc, into an empty string. where as var_dump($array) prints values like below array(2) { [0]= NULL// Does this convert to null to NULL? null is case-insensitive, so it doesn't matter how you type it. [1]= NULL } var_dump converts null into the string NULL. Can you tell me why the above difference? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace_callback(), how to pass function argument/param?
On Sun, Mar 30, 2008 at 1:17 AM, Micky Hulse [EMAIL PROTECTED] wrote: Hi, This is probably simple to answer for most of ya'll, but... preg_replace_callback($f, 'mah_processTags', $text); Besides the matches, how would I pass function args/param to mah_processTags()? For example, I would like to do something like this: preg_replace_callback($f, 'mah_processTags($arg1)', $text); preg_replace_callback($f, 'mah_processTags(\'$0\', $arg1)', $text); Does this work? function mah_processTags($matches, $arg1) { ... } Is this even possible? I just want to pass-in $arg1 along with the matches. :) Possible? Many thanks in advance!!! Cheers, Micky -- Wishlist: http://tinyurl.com/22xonb Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace_callback(), how to pass function argument/param?
On Sun, Mar 30, 2008 at 9:37 PM, Micky Hulse [EMAIL PROTECTED] wrote: Casey wrote: preg_replace_callback($f, 'mah_processTags(\'$0\', $arg1)', $text); Does this work? Awww, does not seem to work. :( But maybe I need to dink with the code a bit more... I would like to avoid setting a global here. :D Thanks for the help Casey! I will let you know if I get it working. I may just have to think of a different approach here. Cheers, Micky Hmmm. I've searched around, and it seems that only a global would work :/ -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_replace_callback(), how to pass function argument/param?
On Sun, Mar 30, 2008 at 10:06 PM, Micky Hulse [EMAIL PROTECTED] wrote: Casey wrote: Hmmm. I've searched around, and it seems that only a global would work :/ Thanks for the help Casey! I really appreciate it. :) Yah, I think I will use a global for now... Until I can think of an alternative coding approach. Have a good one! Cheers, Micky What does mah_process_tags do anyway? XD -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract escaped quoted strings
On Mar 29, 2008, at 4:16 PM, Adam Jacob Muller [EMAIL PROTECTED] wrote: Hi, Have a potentially interesting question here, wondering if anyone has done this one before and could shed some light for me. I have a bit of PHP code that needs to extract some quoted strings, so, very simply: hello perfectly fine and works great but, it should also be able to extract hel\lo bit more complex now Ideally, it would also handle hel\\lo properly it should also handle hel\\\lo Any ideason how to do this? attempts to write a PCRE to do this are so-far unsuccessful, i'm sure I could badger some PHP code into doing it perhaps, but i'd love some elegant PCRE solution that thus- far evades me :( Any ideas are appreciated. -Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ?php $string = \he\\\llo\; // he\llo $parsed = eval('return ' . $string . ';'); echo $parsed; // hello ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new lines in textareas?
On Sat, Mar 29, 2008 at 9:26 PM, Mary Anderson [EMAIL PROTECTED] wrote: Hi all, I have a php script which produces text which is to be displayed in a textarea. I have the wrap for the text area set to 'hard'. I need to have newlines inserted in the text. \n and br don't work. They just get quoted literally in the text. I suspect I need to use htmlspecialchars , but don't know what special character to feed it. Apologies if this should go to an HTML forum. I checked several archives and did not find anything useful. (They tended to tell me to put in \n or br!) Thanks Mary Anderson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php \n, or just a plain line break, should work. ?php echo 'textareaHello, My favorite color is blue. Signed, Me!'; ? Should work. -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert a string to integer
On Fri, Mar 28, 2008 at 12:48 AM, Alain Roger [EMAIL PROTECTED] wrote: Hi, i know this topic is obvious but i have a strange behavior and i'm getting crazy. my stored procedure returns me a string. string can be an email or a message error = '-1', '-2', '-3' when i check if the string contains only digit, i use ctype_digit(mystring) but any way it returns me false... i suppose that for -1, -2, -3 the - is taken as character and not a digit. i tried also to cast it before into integer thanks ctype_digit((int)mystring), but it does not work. so how can i solve this issue ? thx -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 is_numeric() -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert associative array to ordinary array
On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown [EMAIL PROTECTED] wrote: On Fri, Mar 28, 2008 at 2:27 PM, It Maq [EMAIL PROTECTED] wrote: Hi, i have an associative array and i want to use it as an ordinary array, is that possible? what i mean is instead of $arr['fruit'] i want to call it by its position in the array $arr[3] Did you try? -- /Daniel P. Brown Forensic Services, Senior Unix Engineer 1+ (570-) 362-0283 $numbered_array = array_values($associative_array); -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
On Mar 28, 2008, at 4:27 PM, Lamonte [EMAIL PROTECTED] wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: ?php $image = smiley.png; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = FF; $oldhex = FCFF00; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH$height;$cloneH++) { for($x=0;$x$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header(Content-Type: {$data['mime']}); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb 16) 0xFF; $g = ($rgb 8) 0xFF; $b = $rgb 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 $b == $b2 $g == $g2 ) return true; return false; //echo $r $r2, $g $g2, $b $b2; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. ?php function toRGB($color) { return array('r' = ($color 16) 0xFF, 'g' = ($color 8) 0xFF, 'b' = $color 0xFF); } function toColor($r, $g, $b) { return $r * $g * $b; } $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y $h; $y++) { for ($x = 0; $x $w; $x++) { extract(toRGB(imagecolorat($im, $x, $y))); if ($r = 0xCC $g = 0xCC $b = 0x33) imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); } } header('Content-type: image/png'); imagepng($im); ? :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
I have an annoying habit of not using comments :) Explanations are inline. On Mar 28, 2008, at 7:10 PM, Lamonte [EMAIL PROTECTED] wrote: Casey wrote: On Mar 28, 2008, at 4:27 PM, Lamonte [EMAIL PROTECTED] wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: ?php $image = smiley.png; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = FF; $oldhex = FCFF00; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH$height;$cloneH++) { for($x=0;$x$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header(Content-Type: {$data['mime']}); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb 16) 0xFF; $g = ($rgb 8) 0xFF; $b = $rgb 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 $b == $b2 $g == $g2 ) return true; return false; //echo $r $r2, $g $g2, $b $b2; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. ?php function toRGB($color) { return array('r' = ($color 16) 0xFF, 'g' = ($color 8) 0xFF, 'b' = $color 0xFF); } This function returns an array of red, green, and blue from an integer like 0xFF. function toColor($r, $g, $b) { return $r * $g * $b; } This function is basically the opposite of the above. (the integer value from red, green, and blue) $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y $h; $y++) { for ($x = 0; $x $w; $x++) { Loop through the pixels. extract(toRGB(imagecolorat($im, $x, $y))); Take the values from the array return of toRGB so we can use $r, $g, and $b instead of $array['r'], etc. if ($r = 0xCC $g = 0xCC $b = 0x33) After some trial and error (looking at color charts), any red CC, green CC, and blue 33 is some shade of yellow. imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); The expression inside toColor() is my attempt to calculate the correct shade of red from the shade of yellow. } } header('Content-type: image/png'); imagepng($im); ? :) I don't understand half of that, can you explain what you did? (it works) I was more trying to fix my problem then recoding the whole thing though. I hope that helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] munge / obfuscate ?
On Mar 28, 2008, at 7:15 PM, Jack Sasportas [EMAIL PROTECTED] wrote: -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 10:02 PM To: Joey Cc: PHP Subject: RE: [PHP] munge / obfuscate ? Hi Joey, Please keep responses on the list so others can also benefit from the learning process. Comments below... On Thu, 2008-03-27 at 21:46 -0400, Joey wrote: -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 9:28 PM To: Joey Cc: PHP Subject: Re: [PHP] munge / obfuscate ? On Thu, 2008-03-27 at 21:10 -0400, Joey wrote: Hi All, I have written an app to allow a person to go online and see a picture we take of them. When we link to the picture I don't want it to be obvious that the URL is Domain.Com/Pix/123.jpg because the next person we take a picture of may be 123.jpg, so I am trying to munge/obfuscate the URL to make it less obvious. ?php $sekret = 'the brown cow stomped on the wittle bug'; $id = isset( $_GET['id'] ) ? (int)$_GET['id'] : 0; $key = isset( $_GET['key'] ) ? (string)$_GET['key'] : ''; if( $key == sha1( $key.':'.$sekret ) ) That should have been: if( $key == sha1( $id.':'.$sekret ) ) { header( 'Content-Type: image/jpg' ); readfile( /images/not/in/web/path/$id.jpg ) exit(); } // // Failure... tell them to bugger off :) // header( 'Content-Type: image/jpg' ); readfile( '/images/wherever/you/please/buggerOff.jpg' ); exit(); ? Sorry to be such a newbie... I basically would call this function lets say like: munge( $url ); end in the end be returned the munged url, however, I don't understand the values you have like the readfile with that url -vs- failure? I didn't munge... I provided code for a script that sends the requested image if it was requested with the appropriate key (presumably set wherever the image was linked). If the key doesn't validate then another image is presented. It can say bugger off, it can say not found, it can say whatever you please. By placing the images outside the web root and using a script like this you are virtually guaranteed the visitor can't just request images by making a lucky guess. Let's say the above script was called: getUserImage.php Then you might have the following in your HTML: img src=getUserImage.php? id=123amp;key=4fad1fea72565105d84cb187d1a3ed3bfb9 aba3b / I understand what is happening here, however I really want something simple like: $link =http://www.whataver.com/whateverpath/;; $image = 123456; new_image = munge($image); new_link = $link . $new_image; or maybe new_link = munge($link . $image); Which would encode the whole link. Either way this is what would go into the email message we send out. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could use base64_encode/decode. Or... function bitshift_encode($i) { return $i 3; } function bitshift_decode($i) { return $i 3; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] GD, changing an images pixel color, color matching, fuzzy picture
On Mar 28, 2008, at 7:38 PM, Lamonte [EMAIL PROTECTED] wrote: Casey wrote: I have an annoying habit of not using comments :) Explanations are inline. On Mar 28, 2008, at 7:10 PM, Lamonte [EMAIL PROTECTED] wrote: Casey wrote: On Mar 28, 2008, at 4:27 PM, Lamonte [EMAIL PROTECTED] wrote: Okay I created a script that changes a basic smiley face into a red smiley face..but it doesn't replace all the yellow, it looks like a yellow shadow in the background: ?php $image = smiley.png; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = FF; $oldhex = FCFF00; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec (substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH$height;$cloneH++) { for($x=0;$x$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header(Content-Type: {$data['mime']}); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb 16) 0xFF; $g = ($rgb 8) 0xFF; $b = $rgb 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 $b == $b2 $g == $g2 ) return true; return false; //echo $r $r2, $g $g2, $b $b2; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi! I have absolutely no clue if this will work. This has been typed directly into my mail client, so no guarantees. ?php function toRGB($color) { return array('r' = ($color 16) 0xFF, 'g' = ($color 8) 0xFF, 'b' = $color 0xFF); } This function returns an array of red, green, and blue from an integer like 0xFF. function toColor($r, $g, $b) { return $r * $g * $b; } This function is basically the opposite of the above. (the integer value from red, green, and blue) $image = 'smiley.png'; list($w, $h) = getimagesize($image); $im = imagecreatefrompng($image); for ($y = 0; $y $h; $y++) { for ($x = 0; $x $w; $x++) { Loop through the pixels. extract(toRGB(imagecolorat($im, $x, $y))); Take the values from the array return of toRGB so we can use $r, $g, and $b instead of $array['r'], etc. if ($r = 0xCC $g = 0xCC $b = 0x33) After some trial and error (looking at color charts), any red CC, green CC, and blue 33 is some shade of yellow. imagesetpixel($im, $x, $y, toColor(($r + $g) / 2, 0, $b)); The expression inside toColor() is my attempt to calculate the correct shade of red from the shade of yellow. } } header('Content-type: image/png'); imagepng($im); ? :) I don't understand half of that, can you explain what you did? (it works) I was more trying to fix my problem then recoding the whole thing though. I hope that helps. The thing is, it returns black. not red. Oh. Replace the toColor function with the imagecolorallocate function and add $im as the first parameter. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date math
(top-posting!) Add either the round function or ceil function. On Mar 25, 2008, at 6:47 AM, Ron Piggott [EMAIL PROTECTED] wrote: Could someone then help me modify the PHP script so I won't have this timezone issue? I don't understand from looking at the date page on the PHP web site the change(s) I need to make. Thanks, Ron ? $date1 = strtotime($date1); $date2 = strtotime($date2); $factor = 86400; $difference = (($date1 - $date2) / $factor); On Mon, 2008-03-24 at 07:24 -0700, Jim Lucas wrote: Ron Piggott wrote: I have this math equation this list helped me generate a few weeks ago. The purpose is to calculate how many days have passed between 2 dates. Right now my output ($difference) is 93.958333 days. I am finding this a little weird. Does anyone see anything wrong with the way this is calculated: $date1 = strtotime($date1); (March 21st 2008) $date2 = strtotime($date2); (December 18th 2007) echo $date1 = 1206072000 echo $date2 = 1197954000 #86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days worth of seconds) $factor = 86400; $difference = (($date1 - $date2) / $factor); As Casey suggested, it is a timestamp issue. Checkout my test script. http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php plaintext?php $date1 = strtotime('March 21st 2008'); //(March 21st 2008) echo date1 = {$date1}\n; $date2 = strtotime('December 18th 2007'); //(December 18th 2007) echo date2 = {$date2}\n; $date1 = 1206072000; echo date('c', $date1).\n; $date2 = 1197954000; echo date('c', $date2).\n; #86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days worth of seconds) $factor = 86400; $difference = (($date1 - $date2) / $factor); echo $difference.\n; -- 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] Cookie Trouble: getting the information back out...
On Mar 25, 2008, at 6:11 PM, Mark Weaver [EMAIL PROTECTED] wrote: Hi all, I suspect I already know part of the answer to this, but I'm not sure which way to go with it. I've got a project I'm working on and one of the things it's got to do is set cookies and then read them later. When the app was first written I was doing everything in PERL and cookies are fairly straight-forward, however I'm finding cookies in PHP somewhat problematic. Setting the cookie is a snap, however getting the info back out is, well... problematic. this is basically what I'm doing, what I'm seeing in the cookie, and what I'm getting back out. Setting the cookie == $values = blah|blah|blah; setcookie(cookiename, $values, time()+$timevalue); Inside the Cookie == Content: blah%7Cblah%7Cblah Getting info Out Of Cookie == list($first,$second,$third) = explode(|, $values); Cookie Test Page == if (isset($_COOKIE[cookiename])){ list($first,$second,$third) = explode('|',$_COOKIE[cookiename]); echo pI found your cookie/p\n; echo pThe following Values were Contained in the cookie:BR Username: $firstBR Password: $secondBR Type: $third/p\n; } else{ echo pI wasn't able to find your cookie./p\n; } Now, I've constructed a cookie_test.php page to check things out and the strange behavior I'm seeing is, upon first execution I get the else block, but if I hit the browser's reload button I get the if block. At first I thought the cookie wasn't being read at all because of weird characters, but then upon reloading the page and seeing the if block being displayed I'm thoroughly confused. It's gotta something simple I'm missing. and I swear if someone tells me to RTFM I'm gonna shit and go blind cause I haven't got a clue as to which part of the FM to read concerning this. :) thanks, -- Mark - the rule of law is good, however the rule of tyrants just plain sucks! Real Tax Reform begins with getting rid of the IRS. == Powered by CentOS5 (RHEL5) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Did you forget the ?php ? tags? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie Trouble: getting the information back out...
On Mar 25, 2008, at 7:12 PM, Andrew Ballard [EMAIL PROTECTED] wrote: On Tue, Mar 25, 2008 at 9:59 PM, Mark Weaver [EMAIL PROTECTED] wrote: Thank you Andrew... Now it all makes perfect sense. Good grief! there's so much to learn. It seems that Java was easier. ;) That's not specific to PHP. It's just how http works, so it's the same for ASP, Perl, I suspect Java and most (if not all) other languages. There might be a language that sets a cookie when you assign a value to a special cookie variable, but I'm not familiar with any. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php JavaScript, but that's already on the client. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about linux editor
On Mon, Mar 24, 2008 at 7:28 PM, Sudhakar [EMAIL PROTECTED] wrote: i need to connect to the linux server using an editor. can anyone suggest which would be an ideal linux editor to connect to the server. apart from the ip address, username and password are there any other details i would need to connect to the server. please advice. thanks. Putty! -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about linux editor
On Mon, Mar 24, 2008 at 8:09 PM, Mark Weaver [EMAIL PROTECTED] wrote: Casey wrote: On Mon, Mar 24, 2008 at 7:28 PM, Sudhakar [EMAIL PROTECTED] wrote: i need to connect to the linux server using an editor. can anyone suggest which would be an ideal linux editor to connect to the server. apart from the ip address, username and password are there any other details i would need to connect to the server. please advice. thanks. Putty! er... no... he said from Linux! :) No, he said /to/ Linux! :0 -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ob_start: Capturing STDOUT and STDERR
On Sun, Mar 23, 2008 at 6:08 PM, Greg Sims [EMAIL PROTECTED] wrote: Hey There, I looked at the ob_start manual and found a segment of code that can be used to capture the output of a shell script and place it into a log file. One of the entries indicates this should work for both STDOUT and STDERR (29-Mar-2007). I wrote the following piece of code to test it out. function logger($buffer) { $handle = fopen('/var/log/test.log', 'a'); fwrite($handle, $buffer); fclose($handle); } ob_start(logger); This will capture the output buffer until the shell terminates when the buffer is dumped to the test.log file. This is a simple mechanism and it works really well to keep STDOUT from going to the console and logging it. Unfortunately, STDERR continues to go to the console which is what I am working to avoid. I would like to capture STDOUT and STDERR using this technique. I am working to create a self contained script that does not rely on some external script to capture the output. The actual application needs to perform some post-processing of the output buffer at the end of the script. Any pointers in the correct direction would be helpful! Thanks, Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could use set_error_handler() and make your own function to echo out the error. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date math
On Sun, Mar 23, 2008 at 9:17 PM, Ron Piggott [EMAIL PROTECTED] wrote: I have this math equation this list helped me generate a few weeks ago. The purpose is to calculate how many days have passed between 2 dates. snip $date1 = strtotime($date1); (March 21st 2008) $date2 = strtotime($date2); (December 18th 2007) echo $date1 = 1206072000 echo $date2 = 1197954000 Seems to be a time zone issue.1206057600 is the actual timestamp for March 21st, 2008 GMT. I don't know what time zone 1206072000 is is. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting \u0000 in a string...
On Mon, Mar 17, 2008 at 3:56 AM, Mikey [EMAIL PROTECTED] wrote: Hi! I was wondering if anyone here had experienced a simliar problem to mine. I am updating an Oracle XMLType column with XML built using DOM that is populated with values from an Excel spreadsheet saved out as a CSV. My problem is that for certain (apparently) random rows the xml updated will fail with the error: Warning: oci_execute(): OCIStmtExecute: ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00217: invalid character 0 (\u) Error at line 1 ORA-06512: at SYS.XMLTYPE, line 5 ORA-06512: at line 1 in /path/ob/fu/scated/archive.inc on line 1374 I have googled around and a Java fix for the problem seemed to revolve around a null char being left on the end of the XML string, so I tried stripping the last char from the string but this did not help. I then used an ordUTF8 function I found in the manual notes to see if I could find the null in the string - again, no luck. So my question is whether or not anyone here has a reliable way of detcting and removing \u chars from strings? regards, Mikey -- How about: $str = str_replace(\0, '', $str); -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DOM - Question about \0
On Sun, Mar 16, 2008 at 1:50 AM, dav [EMAIL PROTECTED] wrote: Hi, I have question about \0 character with DOM : ?php $cdata = 'foo' . \0 . 'bar'; $dom = new DOMDocument('1.0', 'utf-8'); $dom-formatOutput = true; $container = $dom-createElement('root'); $blob = $dom-createElement('blob'); $blob-appendChild($dom-createCDATASection($cdata)); $container-appendChild($blob); $dom-appendChild($container); echo 'pre' . htmlentities($dom-saveXML()); /* Result : ?xml version=1.0 encoding=utf-8? root blob![CDATA[foo]]/blob /root */ ? What to do with the character \0 ? encode this character to obtain : ![CDATA[foo00;bar]] ? or skip the character with str_replace(\0, '', $cdata) ? What is the best thing to do ? i like to conserve the \0 because is a blob data Jabber is how to transmit binary ? Sorry for by bad english. Thank you. -- Free pop3 email with a spam filter. http://www.bluebottle.com/tag/5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe the entity #00; works? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] __halt_compiler()
Hi list! __halt_compiler(). Does anyone use it? I've used it obsessively in my past two projects to store data (specifically CSV) in the PHP files. These two projects consisted of only one file, and I didn't want to clutter everything and involve databases and/or XML files. Your thoughts? -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making an interactive RGB color picker
On 3/3/08, Keikonium [EMAIL PROTECTED] wrote: This may not be exactly what you think, but I didn't know how else to word the title. I basically need to make a script that will go through every possible color combination and print them to look just like (or similar) to the windows color picker. I need it in the format X-Y-Z. For example: 255-255-255 255-254-254 255-253-253 What I have so far is this: *** ?php $break = printbr; $n1 = 255; $n2 = 12; $n3 = 186; $output = print \$drawrect(\$get(color_x),\$get(color_y),\$get(color_w),\$get(color_h),brushColor-$n1-$n2-$n3 penColor-$n1-$n2-$n3) \$button2(\$get(color_x),\$get(color_y),0,0,\$get(color_w),\$get(color_h),,,PVAR:SET:colorize_global:brushcolor-$n1-$n2-$n3 pencolor-$n1-$n2-$n3,TOOLTIP:\$n1-$n2-$n3\) ; $output ? *** The $drawrect, $button2, and $get are NOT php functions, but to be printed as actual text (which is why I have escaped them with the backslash). Anyways, I thought it would be easiest to separate each R-G-B value into its own variable ($n1, $n2, and $n3). That way I could just use some code (regex?) to cycle through the numbers 0 to 255. The HARD part (that I can't seem to even think of a way to make it possible) is to change JUST the G and B values while keeping the R value at 255. Then when the G and B values both hit 0, the R value is set to 254 and repeated until it also hits 0 with the other two. I think (?) that will do every possible color? I also need to print each string with the individual color output, and I don't know how to do that either. In short, I would like something that looks just like the windows color picker, and when each pixel of it is clicked, it will show me the R-G-B value in the format I would like. If anyone understands what I am after,and could help, that would be awesome! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php HTML a href=color.phpimg src=colormap.png ismap=ismap //a PHP color.php list($coords) = array_keys($_GET); $coords = explode(',', $coords); // Easier way...? $im = imagecreatefrompng('colormap.png'); $color = imagepixelat($im, $coords[0], $coords[1]); I wouldn't do it like this, though. I'd use Javascript. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output buffering in CLI script.
On Thu, Feb 28, 2008 at 3:39 AM, Jochem Maas [EMAIL PROTECTED] wrote: hi there, I can't seem to manage to buffer output (of an included file) in a CLI script, the following does not work: // buffer output so we can avoid the shebang line being output (and strip it from the output we log) $oldIFvalue = ini_set('implicit_flush', false); ob_start(); if ([EMAIL PROTECTED] $script) { ob_end_clean(); } else { $output = explode(\n, ob_get_clean()); if ($output[0] preg_match('%^#!\/%', $output[0])) unset($output[0]); } ini_set('implicit_flush', $oldIFvalue); the reason I'm wanting to do this is, primarily, in order to stop the shebang line that *may* be present in the included script from being output to stdout. I use Windows, so I don't need the shebang line. But if I'm correct and the shebang line is: #!/usr/bin/php , shouldn't it be considered a comment, because of the #? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making sure an include file works
On Thu, Feb 28, 2008 at 7:50 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Thu, 2008-02-28 at 18:58 -0800, Richard S. Crawford wrote: I'm trying to figure out a way to make sure an included PHP file has no syntax errors before actually including it as a part of project. Is this even possible? I'm running into brick walls. I don't believe there is a function to do this. What can be done though is to call the cli binary with the -l flag and have the file syntax checked that way. php -l /path/to/the/source It wouldn't be very fast though as a solution. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' http://us.php.net/manual/en/function.php-check-syntax.php -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reverse string without strrev();
On Thu, Feb 28, 2008 at 3:25 AM, Shelley [EMAIL PROTECTED] wrote: Hi all, What do you think is the best way to display string 'abcdef' as 'fedcba'? Any ideas appreciated. Thanks in advance. -- Regards, Shelley ...What is wrong with strrev()? Am I missing something important here? Some multibyte character issue? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 8:38 PM, Nathan Rixham [EMAIL PROTECTED] wrote: Robert Cummings wrote: On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: Robert Cummings wrote: On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: don't say I didn't warn ya fellow nathan! #!/usr/bin/php ?php function sillyFunc() { return array('a' = 1, 'b' = 2, 'c' = 3, 'd' = 4, 'e'='some string'); } echo !${~${''}='sillyFunc'}=${''}().${~${''}}['e'] . PHP_EOL; I was ready to use this system everywhere in my code until I saw that it generates an E_STRICT... now I'll just have to keep with what I usually do. Cheers, Rob. scratch the former! FIXED echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; Ok, I lied... I'm not really gonna use it. Interesting tidbit of obfuscation though. BTW... the following is shorter: echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; Cheers, Rob. but doesn't work over here.. php 5.2.4 5 Doesn't work for me either. Here's mine: function ReturnArray() { return array('a' = 'f', 'b' = 'g', 'c' = 'h', 'd' = 'i', 'e' = 'j'); } echo ${(${0}=ReturnArray())0}['a']; -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo returnArray()['a']; // workaround
On Thu, Feb 28, 2008 at 8:42 PM, Casey [EMAIL PROTECTED] wrote: On Thu, Feb 28, 2008 at 8:38 PM, Nathan Rixham [EMAIL PROTECTED] wrote: Robert Cummings wrote: On Thu, 2008-02-28 at 23:27 -0500, Robert Cummings wrote: On Fri, 2008-02-29 at 04:04 +, Nathan Rixham wrote: Robert Cummings wrote: On Fri, 2008-02-29 at 00:18 +, Nathan Rixham wrote: don't say I didn't warn ya fellow nathan! #!/usr/bin/php ?php function sillyFunc() { return array('a' = 1, 'b' = 2, 'c' = 3, 'd' = 4, 'e'='some string'); } echo !${~${''}='sillyFunc'}=${''}().${~${''}}['e'] . PHP_EOL; I was ready to use this system everywhere in my code until I saw that it generates an E_STRICT... now I'll just have to keep with what I usually do. Cheers, Rob. scratch the former! FIXED echo !(${~${''}='sillyFunc'}=${''}()).${~${''}}['e'] . PHP_EOL; Ok, I lied... I'm not really gonna use it. Interesting tidbit of obfuscation though. BTW... the following is shorter: echo ${~${''}='sillyFunc'}['e'] . PHP_EOL; Cheers, Rob. but doesn't work over here.. php 5.2.4 5 Doesn't work for me either. Here's mine: function ReturnArray() { return array('a' = 'f', 'b' = 'g', 'c' = 'h', 'd' = 'i', 'e' = 'j'); } echo ${(${0}=ReturnArray())0}['a']; -- -Casey By the way, this could be compressed simply to echo ${!${!1}=ReturnArray()}['a']; I don't know why I'm continuing this... but for the truly crazy: function w($t) { $t = array('f' = '...'); return 't'; } echo ${w($t)}['f']; -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Are these Truthful Proof about PHP ??
On Wed, Feb 27, 2008 at 10:03 AM, Dare Williams [EMAIL PROTECTED] wrote: Dear Developers, http://msdn2.microsoft.com/en-us/library/aa479002.aspx I read an Article on the above Microsoft website stating the reason why to Migrate from PHP to ASP.NET. So can you please justify this proofs from Microsoft and let everybody knows if they are all TRUE and MEANIFUL atall or they are just cheap lies to backup their product. Please advice? Thanks. Williams. That article does not state the reason why to migrate from PHP to ASP.NET. It describes the differences between the two. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ZCE guidance needed
On Wed, Feb 27, 2008 at 8:09 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Wed, Feb 27, 2008 at 10:31 PM, Shelley [EMAIL PROTECTED] wrote: Greetings all, Im just need some guidance of how to prepare for the ZCE exam. Is there somebody passed the exam? Any help infor is highly appreciated. i read the php architect book and paid for 5 of their sample tests. http://www.phparch.com/c/books/id/0973862149 some of the questions on the test are really obscure, not really like about the language as much as the set of functions that ship w/ it. they try and trip you up, like asking very specific questions about some of the functions and so forth. good news is a low score still makes the passing grade ;) -nathan There's a test for PHP? Wow, I never knew that. Is there some kind of free online test to determine my [self-taught] PHP knowledge? :D -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Guidance
On Wed, Feb 27, 2008 at 1:04 PM, Nathan Rixham [EMAIL PROTECTED] wrote: Matty Sarro wrote: I understand and agree completely, and I really appreciate the help. My goal isn't so much to keep from re-writing code, but to have a pretty firm foundation to stand on before I really begin. I mean, with c++ or c, all I needed was the language, and that was pretty much it. I could do everything from there. This seems a lot more like its a marriage of a ton of different technologies :) On Wed, Feb 27, 2008 at 3:32 PM, Daniel Brown [EMAIL PROTECTED] wrote: On Wed, Feb 27, 2008 at 3:01 PM, Stut [EMAIL PROTECTED] wrote: Maybe it's just me but I usually end up rewriting everything I write at least twice. That's just a fact of life and I've found that I end up with far better code that way than I do by trying to get it right first time. It also tends to be quicker. [snip!] In short, learn by doing. It's served me well. I made it even shorter, Stut. ;-P He's exactly right, Matty. It's a form of evolution called versioning. No programmer gets everything perfect the first (or usually even second, third, eighth) time. Good, usable, lasting code will be written and rewritten very often. Look at almost any code that's been around and distributed (including the PHP project itself) and you'll notice that there are dozens of versions, because over the years new ideas have come about to make it more productive, more economical, and all-around better. -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? Indeed it is Matty, here's the way I would approach 1 (X)HTML view source and w3schools are your friends here 2 CSS just the basic will get you started, worth reading W3C CSS spec particularly the BOX Model [http://www.w3.org/TR/css3-box/] 3 Make a project website in plain XHTML with CSS 4 ECMAScript (javascript) Make your static website do a couple of nice things with some javascript. you can't expect to program anything we related if you can't format the output! Oddly, I learned JavaScript and PHP before truly learning XHTML. By the way, I really hate font tags, so learn XHTML! Also, if you're learning JavaScript, please learn W3C DOM, and not the document.write(Ugliness). :) -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cannot even come up with the beginning of a regex
2008/2/27 Dotan Cohen [EMAIL PROTECTED]: On 27/02/2008, Zoltán Németh [EMAIL PROTECTED] wrote: sorry that's messed up a bit, as I typed it right here in my mailer ;) preg_replace('/\b([^\s]+)a\b.*/U', '$1A', 'whatever i want that hasa a on the end'); greets Zoltán Németh Thank you very much, Zoltan. Is there a known UTF-8 limitation? Because it works fine for me in English letters (well, the opposite of what I needed but I was able to work with it as which polar I start with was arbitrary), but not in Hebrew letters. For instance, this works as expected: $test=aabacada aa a f; $test=preg_replace('/\b([^\s]+)a\b.*/U', '$1A', $test); print $test; // PRINTS aabacadA aA a f However, this does not: $test=אאבאגאדא אא א ; $test=preg_replace('/\b([^\s]+)ע\b.*/U', '$1א', $test); print $test; // PRINTS אאבאגאדא אא א Am I misunderstanding something, or is there a UTF-8 problem, or something else? Thank you for your assistance, it is much appreciated and I'm learning what I can. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? The a character (97) is different from the א character (1488). $a = html_entity_decode('#1488;'); $test=preg_replace('/\b([^\s]+)' . $a . '\b.*/U', '$1A', $test); Will this work? -- -Casey
Re: [PHP] Ignoring user cancel
On Feb 22, 2008, at 6:19 PM, K T Ligesh [EMAIL PROTECTED] wrote: Hello, I have a php process running on lighty that should continue even if the user presses cancel in his browser. The default behavior is that the web-server will kill the cgi process on user cancellation. Is there some way I can prevent the user cancel from interfering with the php process. Can I ignore the web-server's kill in php or is this a configuration that should be handled at the web-server? Any help is greatly appreciated. Thanks a lot in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ignore_user_abort(true); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with quotes
On Thu, Feb 21, 2008 at 8:04 PM, Mário Gamito [EMAIL PROTECTED] wrote: Hi, Sorry for such a laim question. I have this code: $host = 'http://' . $_SERVER['HTTP_HOST']; foreach($browser as $key = $val){ echo img src=\dcs/ . $key . '.png' . / . ; (...) but it has a bug, I need to add the server domain before the picture, so I did: $host = 'http://' . $_SERVER['HTTP_HOST']; foreach($browser as $key = $val){ echo $host . img src=\dcs/ . $key . '.png' . / . ; (...) But this way, all it echoes is the $host variable. What am I missing here ? Any help would be appreciated. Warm Regards, Mário Gamito Not the problem, but: echo img src=\dcs/ . $key . '.png' . / . ; can be condensed to: echo img src=\dcs/$key.png\ / ; -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form cleaner class
On Thu, Feb 21, 2008 at 8:53 PM, nihilism machine [EMAIL PROTECTED] wrote: What is a better idea? Using this class in my db class and using CleanInput on the sql statements, or using it in the top of the all pages with form input to clean the $_POST's? Also, any ideas or comments on improving the class? ?php class FormCleaner { // Initializer function __construct() { if (count($_POST) 0) { foreach($_POST as $curPostKey = $curPostVal) { $_POST[$curPostKey] = $this-CleanInput($curPostVal); } } } // Clean Form Input public function CleanInput($UserInput) { $allowedtags = b/bi/ih1/h1a/aimgul/ulli/ liblockquote/blockquote; $notallowedattribs = array(@javascript:|onclick|ondblclick| onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress| onkeydown|[EMAIL PROTECTED]); $changexssto = ''; $UserInput = preg_replace($notallowedattribs, $changexssto, $UserInput); $UserInput = strip_tags($UserInput, $allowedtags); $UserInput = nl2br($UserInput); return $UserInput; } } ? Does this line work?: foreach($_POST as $curPostKey = $curPostVal) { $_POST[$curPostKey] = $this-CleanInput($curPostVal); } If I recall correctly, you can't modify the array within a foreach block... or am I going crazy? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form cleaner class
On Thu, Feb 21, 2008 at 8:59 PM, Casey [EMAIL PROTECTED] wrote: On Thu, Feb 21, 2008 at 8:53 PM, nihilism machine [EMAIL PROTECTED] wrote: What is a better idea? Using this class in my db class and using CleanInput on the sql statements, or using it in the top of the all pages with form input to clean the $_POST's? Also, any ideas or comments on improving the class? ?php class FormCleaner { // Initializer function __construct() { if (count($_POST) 0) { foreach($_POST as $curPostKey = $curPostVal) { $_POST[$curPostKey] = $this-CleanInput($curPostVal); } } } // Clean Form Input public function CleanInput($UserInput) { $allowedtags = b/bi/ih1/h1a/aimgul/ulli/ liblockquote/blockquote; $notallowedattribs = array(@javascript:|onclick|ondblclick| onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress| onkeydown|[EMAIL PROTECTED]); $changexssto = ''; $UserInput = preg_replace($notallowedattribs, $changexssto, $UserInput); $UserInput = strip_tags($UserInput, $allowedtags); $UserInput = nl2br($UserInput); return $UserInput; } } ? Does this line work?: foreach($_POST as $curPostKey = $curPostVal) { $_POST[$curPostKey] = $this-CleanInput($curPostVal); } If I recall correctly, you can't modify the array within a foreach block... or am I going crazy? -- -Casey Nevermind, wrong language! :P -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php warning message
On Feb 20, 2008, at 1:29 PM, Yuval Schwartz [EMAIL PROTECTED] wrote: Hello and thank you, Another question, I get a message: *Warning*: feof(): supplied argument is not a valid stream resource in * /home/content/t/h/e/theyuv/html/MessageBoard.php* on line *52* ** And I've tried troubleshooting for a while; I'm pretty sure I'm opening the file handle correctly and everything but I can't get feof or similar functions like fgets to work. Here is my code if you're interested (it's so that I color every 2nd line in the text): *$boardFile = MessageBoard.txt; $boardFileHandle = fopen($boardFile,r); for ($counter = 1; !feof($boardFileHandle); $counter += 1) { $colorLine = fgets(boardFilehandle); if ($counter % 2 == 0) { echo font color='00ff00'$colorline/font; } else { echo $colorline; } The loop looks ugly :/ $colored = false; while (!feof($boardFileHandle)) { $line = fgets($boardFileHandle); if ($colored) echo 'span class=colored', $line, '/spanbr /'; else echo $line, 'br /'; $colored = !$colored; } } fclose($boardFileHandle);* Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Protected ZIP file with password
On Feb 18, 2008 9:07 AM, Richard Lynch [EMAIL PROTECTED] wrote: On Sun, February 17, 2008 1:57 pm, Nick Stinemates wrote: Petrus Bastos wrote: Hi Nick, Sorry, but I forgot to tell you that I can't use this exec neither system commands because they are disabled for security precautions. So, Do you have any other ideas on how can I do that? Sometimes, you can write a cron job that does what you want from the shell, and that has less restrictions, since the php.ini file can be specified/modified on the command line on the fly... Perhaps that would help you here... And a potentially truly UGLY hack... I'm betting that the password protection of the zip file is just a few different bytes in the header portion of a zip... So take an un-protected zip, and password-protect it, and then do a diff and see what changed. Then take that diff output, and just paste it in as the front of the other zip files... Might work. Might make hash of the zip files. Won't know til you try. The RFC makes it sound so confusing. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Source code protection
On Feb 7, 2008 1:50 AM, Richard Heyes [EMAIL PROTECTED] wrote: Greg Donald wrote: On 2/6/08, Richard Heyes [EMAIL PROTECTED] wrote: There's the Zend Encoder at www.zend.com. Though it may be called something else now. Pointless. http://www.phprecovery.com/ Pointless? I think it is exactly the answer to the original persons question. -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software for £299 hosted for you - no installation, no maintenance, new features automatic and free Why not just translate it to C#? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string vs number
On Feb 5, 2008, at 10:43 AM, Eric Butera [EMAIL PROTECTED] wrote: On Feb 5, 2008 1:40 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Feb 5, 2008 1:36 PM, Hiep Nguyen [EMAIL PROTECTED] wrote: hi all, i have this php statement: ? if($rowB[$rowA[0]]=='Y') {echo checked;} ? debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = $rowB ['54']. is this possible? how do i force $rowA[0] to be a string ('54')?http://www.php.net/unsub.php php should handle the conversion internally for you. if you want to type cast a value to a string, simply do (string)$varname -nathan I was thinking about saying that, but php is loosely typed, so 54 == '54'. I'm thinking something else is wrong here. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I believe this is the difference with arrays: $a = array(2 = foo); Array(0 = null, 1 = null, 2 = foo) $a = array(2 = foo); Array(2 = foo) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] flash with PHP
On Feb 3, 2008, at 12:23 AM, Alain Roger [EMAIL PROTECTED] wrote: Hi, i would like to have a flash menu in my PHP website. this is no problem. My problem is how to exchange data between PHP andFlash (in both direction). i found a lot of posts on this theme, but nothing with really works under ActionScript 3 and PHP. does anyone already solved such topic ? thx. -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 var loadvars = new LoadVars(); http://www.google.com/search?q=loadvars -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Jacco van Hooren
On Feb 3, 2008 1:51 AM, Jim Lucas [EMAIL PROTECTED] wrote: Nathan Rixham wrote: wish he'd turn that auto responder off.. *sigh* - he's now top of my contacts in gtalk.. That is his way of getting to the top of next weeks PostTrack Report from Dan:) Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could set up Gmail's filters. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resetting a session variable
On Feb 3, 2008 10:25 AM, Per Jessen [EMAIL PROTECTED] wrote: Ron Piggott wrote: What is the command to reset a session variable --- essentially deleting all of the values it contains? Ron I haven't checked, but how about unset() ? /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php unset($_SESSION); or $_SESSION = array(); -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] flash with PHP
On Feb 3, 2008 10:44 AM, Alain Roger [EMAIL PROTECTED] wrote: this is right under actionscript 2.0... i'm working under actionscript 3.0 :-) On Feb 3, 2008 7:28 PM, Casey [EMAIL PROTECTED] wrote: On Feb 3, 2008, at 12:23 AM, Alain Roger [EMAIL PROTECTED] wrote: Hi, i would like to have a flash menu in my PHP website. this is no problem. My problem is how to exchange data between PHP andFlash (in both direction). i found a lot of posts on this theme, but nothing with really works under ActionScript 3 and PHP. does anyone already solved such topic ? thx. -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 var loadvars = new LoadVars(); http://www.google.com/search?q=loadvars -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 Does this work? http://www.peterelst.com/blog/2007/11/28/actionscript-30-wheres-my-loadvars/ -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about preg_replace, please help !
On Feb 3, 2008, at 5:00 PM, LKSunny [EMAIL PROTECTED] wrote: ? $txt = eof a a a eof; //i just want replace start to first \r\n\r\n //how can i do ? //i want out put /* */ print preg_replace(What's is this ?, , $txt); //Thank You !! ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php list(, $result) = explode(\r\n\r\n, $string, 2); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] about preg_replace, please help !
On Feb 3, 2008 9:04 PM, LKSunny [EMAIL PROTECTED] wrote: this i know. but i need use preg_replace. any body can help me, thank you very much !! Casey [EMAIL PROTECTED] ???:[EMAIL PROTECTED] On Feb 3, 2008, at 5:00 PM, LKSunny [EMAIL PROTECTED] wrote: ? $txt = eof a a a eof; //i just want replace start to first \r\n\r\n //how can i do ? //i want out put /* */ print preg_replace(What's is this ?, , $txt); //Thank You !! ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php list(, $result) = explode(\r\n\r\n, $string, 2); -- Why do you need preg_replace? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Timeout while waiting for a server-client transfer to start (large files)
On Feb 1, 2008, at 5:45 PM, szalinski [EMAIL PROTECTED] wrote: On Thu, 31 Jan 2008 07:13:55 -, Per Jessen [EMAIL PROTECTED] wrote: Richard Lynch wrote: Your script is reading the whole file, 64 measly bytes at a time, into a monstrous string $tmp. Then, finally, when you've loaded the whole [bleep] file into RAM in $tmp, you just echo it out, right? Don't do that. :-) while (!feof($fp)){ echo fread($fp, 2048); } And if the OP is opening the file anyway, he might as well use readfile() instead. /Per Jessen, Zürich Well I got it to work, much thanks to Richard Lynch, but now everytime I download a file, it is corrupt. For example, when I download small .rar file, just to test, it is always corrupt ('Unexpected end of archive'). I also cleared my browser cache just to be sure, but same problem. Here is the code as it stands. I just can't get my head around why it wouldn't be working as it is... ?php //ob_start(); //ob_end_flush(); //ob_implicit_flush(TRUE); $rslogin = ''; $rspass = ''; $link = addslashes(trim($_POST['link'])); function cut_str($str, $left, $right) { $str = substr(stristr($str, $left), strlen($left)); $leftLen = strlen(stristr($str, $right)); $leftLen = $leftLen ? -($leftLen) : strlen($str); $str = substr($str, 0, $leftLen); return $str; } // Get the full premium link, and store it in $full_link after the redirect. *Surely* there is an easier way to get redirections? if(strlen($link)0) { $url = @parse_url($link); $fp = @fsockopen($url['host'], 80, $errno, $errstr); if (!$fp) { $errormsg = Error: b$errstr/b, please try again later.; echo $errormsg; exit; } $vars = dl.start=PREMIUMuri={$url['path']} directstart=1; $out = POST {$url['path']} HTTP/1.1\r\n; $out .= Host: {$url['host']}\r\n; $out .= User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n; $out .= Authorization: Basic .base64_encode({$rslogin}: {$rspass}).\r\n; $out .= Content-Type: application/x-www-form-urlencoded\r \n; $out .= Content-Length: .strlen($vars).\r\n; $out .= Connection: Close\r\n\r\n; fwrite($fp, $out); fwrite($fp, $out.$vars); while (!feof($fp)) { $string .= fgets($fp, 256); } //Tell us what data is returned //print($string); @fclose($fp); if (stristr($string, Location:)) { $redirect = trim(cut_str($string, Location:, \n)); $full_link = addslashes(trim($redirect)); } //print($string); //print(htmlbodyh1.$full_link./h1); if ($full_link) { //Get info about the file we want to download: $furl = parse_url($full_link); $fvars = dl.start=PREMIUMuri={$furl['path']}directstart=1; $head = Host: {$furl['host']}\r\n; $head .= User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n; $head .= Authorization: Basic .base64_encode({$rslogin}: {$rspass}).\r\n; $head .= Content-Type: application/x-www-form-urlencoded\r\n; $head .= Content-Length: .strlen($fvars).\r\n; $head .= Connection: close\r\n\r\n; $fp = @fsockopen($furl['host'], 80, $errno, $errstr); if (!$fp) { echo The script says b$errstr/b, please try again later.; exit; } fwrite($fp, POST {$furl['path']} HTTP/1.1\r\n); fwrite($fp, $head.$fvars); while (!feof($fp)) { //Keep reading the info until we get the filename and size from the returned Header - is there no easy way //of doing this? I also don't like the way I have to 'find' the redirected link (above).?? $tmp .= fgets($fp, 256); $d = explode(\r\n\r\n, $tmp); // I tried changing this to if ($d), { etc.., (instead of $d[1]) and the download of the rar file *wasn't* corrupt, it just had a filetype of x-rar-compressed instead of //application/octet-stream, and the filesize was 'unknown' - now this is just confusing me...! So i think (and guess) the problem of the file corruption is here, //because it must add some data to the filestream which corrupts it. Darn. if($d[1]) { preg_match(#filename=(.+?)\n#, $tmp, $fname); preg_match(#Content-Length: (.+?)\n#, $tmp, $fsize); $h['filename'] = $fname[1] != ? $fname[1] : basename($furl['path']); $h['fsize'] = $fsize[1]; break; } } @fclose($fp); $filename = $h['filename']; $fsize = $h['fsize']; //Now automatically download the file: @header(Cache-Control:); @header(Cache-Control: public); @header(Content-Type: application/octet-stream); @header(Content-Disposition: attachment;
Re: [PHP] How can I do this -- method chaining
On Jan 30, 2008 4:53 PM, Jochem Maas [EMAIL PROTECTED] wrote: Richard Lynch schreef: I believe the constructor returns the object created, with no chance in userland code of altering that fact, over-riding the return value, or any other jiggery-pokery to that effect. New causes the constructor to be called in the first place, and that's about it. The assignment to a variable is done by the assignment operator = and is not required if you don't have any need to actually keep the object around in a variable. I thought that's what I said. maybe less clearly :-) I don't think constructors return the object: ?php class foo { private $bar; public function __construct($bar) { echo In constructor\n; $this-bar = $bar; } } $x = new foo(...); var_dump($x-__construct()); # NULL ? -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] determine file-upload's tmp-filename
On Jan 26, 2008 3:57 PM, Michael Fischer [EMAIL PROTECTED] wrote: hi there, is there a way to determine the tmp-filename of a file upload while the upload is still in progress? the tmp-file is stored in /tmp and it's name is something like PHP. what i would like to do is: i want to upload a file via a html-form and while the upload is in progress make repeatedly ajax-requests to a php-script on the server that replies the size of the tmp file (the amount of data that was already uploaded). So in this script i need to know what the tmp-filename is. or do you think this is a completely useless approach? lg, Michi Will this help? http://tomas.epineer.se/archives/3 -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] upload problem
On Jan 22, 2008, at 5:01 PM, nihilism machine [EMAIL PROTECTED] wrote: any ideas why this does not work? class upload { function upload() { upload::uploader(); } function uploader() { $FileName = basename($_FILES['upload1']['name']); if (move_uploaded_file($_FILES['upload1']['tmp_name'], $FileName)) { chmod($FileName, 0755); rename($FileName, admin/advertisements/ . $FileName); return $FileName; } else { return Error!; } } } Try deleting the upload() function. Then: $test = new upload(); $filename = test-uploader(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expand variable in comparison
On Jan 19, 2008 9:52 AM, Richard Lynch [EMAIL PROTECTED] wrote: You can cheat like this: define('DEBUG', 1); if (DEBUG || $this-var == $preDefinedStringToTestWith) return true; else return false; At some later date, you change the 1 to 0 in the define() statement. Please tell us WHY you want do what you want to do... On Fri, January 18, 2008 1:50 pm, Marcus wrote: Hi! Is there any way to get the following snippet returning a true? ... $this-var = ? if ($this-var == $preDefinedStringToTestWith) return true; else false; The problem: I don't know, what $preDefinedStringToTestWith is! $this-var can be set to any string. I tried $this-var = ${preDefinedStringToTestWith} but this doesn't get expanded. Thanks for your help, Marcus. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? I *think* you want: return $this-var == $$preDefinedStringToTestWith; http://us.php.net/language.variables.variable -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] avoid server folder reading
On Jan 19, 2008 6:36 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Jan 19, 2008 7:50 PM, Jochem Maas [EMAIL PROTECTED] wrote: my reply was to the OP, not you as such, given that your also answering his question, sorry for the misunderstanding. i think half the time i get confused myself; like this morning when you said show us your exact code, to the OP of the thread, and i was like; 'i just posted my exact code' :) that said I have found it's often a worthy exercise to poke/prod the OP as to what they are really trying to achieve rather than blindly assume that what they are asking is what they really want - this is quite often not the case - I think you;ll agree :-) such was the case w/ the thread where tedd asked about embedding nbsp in the name attribute of a input tag of type submit. everybody was going on about how to handle it on the server side and i was like, just end it w/ a little css. so yeah, i def agree. -nathan Just add a simple index.php to every folder you want to hide, if you want a PHP solution. index.php: header('Location: http://yoursite.com'); -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Bad company This Weekend!
On Jan 18, 2008 9:15 AM, Colin Guthrie [EMAIL PROTECTED] wrote: Maximus Entertainment wrote: _Bad Company – This Saturday Night in Milwaukee, WI_ Great. That's super relevant for 99.9% of this mailing list. Anyone near Milwaukee should go along and punch one of the promoters :D Don't miss this opportunity to see him. Please go to the Richfield Chalet's website (www.richfieldchalet.com/events.php) for more information, or contact the venue at 262-628-4080. Tickets are $20. Print this email out Gasp! They use PHP! -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
On Jan 15, 2008, at 4:54 PM, Ken Kixmoeller -- reply to [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: 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 Maybe you could echo the results of the failed ones and compare. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
On Jan 15, 2008 8:40 PM, Ken Kixmoeller -- reply to [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: 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Þ(c)·ž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 ñº*J 6}Ø+„ -|- 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 It returns the correct value. If you look at the last example, and run base64_decode on MDAwMzEwMDI0NDA0MTMyOQ==, you will get 0003100244041329. -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is some_function()[some_index] invalid syntax?
On Jan 10, 2008, at 8:00 PM, Arlen Christian Mart Cuss [EMAIL PROTECTED] wrote: Hi there, Why is it that if I try to evaluate an index of an array returned by a function immediately, a syntax error is produced? (unexpected '[', expecting ',' or ';') Thanks, Arlen. I've run into this problem. (It works in Javascript .) While I don't know why, you could store it in a temporary variable or use the list() language construct. -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg help!
On Jan 8, 2008, at 5:45 PM, steve [EMAIL PROTECTED] wrote: I have a dir of html files that link to websites, i would like to read the dir and print a list of those files as a link. Which the script i have does. I would like to take this one step further and replace the .html extension with .com so it winds up being: website.com instead of website.html I am apparently having problems getting my head around eregi enough to acomplish this. any help is greatly appreciated. ? $source_dir = ./mydir; $dir=opendir($source_dir); $files=array(); while (($file=readdir($dir)) !== false) { if ($file != . $file != .. strpos(strtolower ($file),.php) === false) { array_push($files, $file); } } closedir($dir); sort($files); foreach ($files as $file) { echo A href='$file'$filebr; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think glob('*.html'); would be easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHTML files showing as blank pages
On Jan 5, 2008, at 10:50 AM, A.smith [EMAIL PROTECTED] wrote: Hi Bastien, thanks for the suggestion, unfortunately I still have no page displayed... thanks Andy. - Original Message From: Bastien Koert [EMAIL PROTECTED] To: A.smith [EMAIL PROTECTED], php-general@lists.php.net php-general@lists.php.net Subject: RE: [PHP] PHTML files showing as blank pages Date: 05/01/08 18:20 Andy, try this AddHandler php5-script .php .phtml #AddType text/html .php .phtml AddType application/x-httpd-php .php .phtml .html .htm bastien Message sent using UK Grid Webmail 2.7.9 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php In the actual page, try replacing ? with ?php. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] which window?
Try adding target=_top or target=_parent to the form element in HTML. On 1/5/08, Bastien Koert [EMAIL PROTECTED] wrote: this would be an html / js issue... why have a popup login in this case? just show the logon in the main window and then do the redirect... bastien To: php-general@lists.php.net From: [EMAIL PROTECTED] Date: Sat, 5 Jan 2008 10:17:55 -0800 Subject: [PHP] which window? Hello; I have a login panel that is opened as a javascript window. In the processing script, a successful login uses the header function to send the user to the restricted content index page. But this page is loading into the javascript window instead of the opener window of the browser. Is it possible to supply a target property to the header() function to display content in a specific window? Or is that strictly an html/javascript issue? I have looked into the header() function but it is unclear to me what all can be done with headers. Thanks in advance for suggestions, info; Jeff K -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Use fowl language with Chicktionary. Click here to start playing! http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image* Functions' Memory Usage
On Jan 4, 2008, at 9:54 AM, Daniel Brown [EMAIL PROTECTED] wrote: On Jan 4, 2008 12:46 PM, Casey [EMAIL PROTECTED] wrote: Greetings, list. I have a web application that generates PNG images that are thousands of pixels high by thousands of pixels wide (using imagepng, etc.). The problem is this takes way too much memory, and the rest of the site becomes too slow. I'm working on something to cache the images, but some suggestions in the meantime would be great. Maybe ImageMagick is faster? Flash?Any suggestions? Thank you very much. It depends on what you are trying to do with the images. Are you randomly-generating data to create patterns, or are you (*gasp*) converting small images into [very pixelized] larger ones? -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. I'm laying many different other (smaller) images over each other at various positions. (I know HTML/CSS and SVG could do this with less trouble, but that would give away my secrets by just viewing the source.) -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image* Functions' Memory Usage
Greetings, list. I have a web application that generates PNG images that are thousands of pixels high by thousands of pixels wide (using imagepng, etc.). The problem is this takes way too much memory, and the rest of the site becomes too slow. I'm working on something to cache the images, but some suggestions in the meantime would be great. Maybe ImageMagick is faster? Flash?Any suggestions? Thank you very much. - Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to secure Flash Video? [Solved?]
On Jan 4, 2008 9:16 PM, tedd [EMAIL PROTECTED] wrote: Hi gang: Here's my logic, so what's wrong with it? My sole concern here is to protect a Video from being stolen and/or being viewed remotely while allowing approved users to view it. It is a fact that anything you present to a user is theirs. There's no stopping them from downloading a Video if they have permission to do so. In fact, that's exactly what they do when they view a Video -- they can't view it in their browser unless their browser has it. Now, I have investigated several ways to protect videos and prevent caching. Some methods are very complex -- but complexity does not always guarantee security. Complexity is more likely to present problems in its application. Sometimes the simplest method is best. The simplest protection method I can think of can be done by using Flash Video Actionscript in concert with php/mysql. It's a simple matter to have the Video run the following prior to displaying: theXML.load(http://example.com/security.php) That's similar to a javascript onload function. Upon loading the Video, the Video will run the script security.php which in-turn will check to see if an approved user is attempting to view the Video. This done by simply checking a user-id session variable in the script that delivers the Video. If that session variable (user-id ) is empty, then the security.php returns nothing. If that session session is not empty, then the script will check the user-id against the database to see if the user has permission to view the Video. If the user does not have permission, then the security.php script returns nothing. If everything checks, then the security.php script will return a key and the Video will check that key against an internal key -- if a match is made, then the video plays. Now, please note that this will also prohibit the user, even after paying for the Video, from downloading the Video for future plays because the Video will always check for a key. Even if the user downloads the Video and takes the Video to a remote player, the Video will still try to run the security script seeking a key. If the security script is not there, then it fails. Even if the user figures out that the Video requires a key, the still user has no way to determine what that internal key is. So, I think this will work. What say all of you? Where have I screwed up? And, please no one liners that solve the entire mess and make me look like a fool. Cheers, tedd I'm not sure if you mean FLV's or SWF's. If you mean FLV's loaded from SWF's, the browser can cache the FLV, and the user can later retrieve it. If you mean SWF's, there are extractors out there. In other words, it's not really possible to completely secure these videos, but this is a fairly good solution, as I see it. -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] best way for PHP page
On Jan 1, 2008 11:17 PM, Alain Roger [EMAIL PROTECTED] wrote: Hi, i would like to improve my coding quality when i use PHP code and for that i would request your help. in my web developer experience, i have to confess that i've never succeeded in spliting PHP code from HTML code. i mean that all my web pages consist of PHP code mixed with HTML code (for rendering pages). Some developers tell it's possible to write only PHP code for web page. i agree with them but only when those PHP pages do not render web elements (write text, display pictures, display formular, ...). the purpose of my post is to know if i can really (at 100%) split client code (display images, write text,...) from server code (move or copy data to DB, create connection objects,...) so what do you think about that ? -- Alain Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 Yes, you can. function foo() { global $data; //Fetch from database, format, etc. etc. //Stuff all the data into $data variable } function bar() { global $data; //Output with HTML } $data = array(); foo(); bar(); I'm pretty sure this is what they mean. -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] First stupid post of the year.
On Jan 2, 2008 12:11 PM, tedd [EMAIL PROTECTED] wrote: At 2:36 PM -0500 1/2/08, Nathan Nobbe wrote: and yes several people posted nearly identical solutions. i know its futile to complain, sort of like the [SOLVED] thing we discussed a while back. well i just find it annoying when people dont bother to read through the currently posted solutions before posting the exact same thing or nearly identical thing themselves. Yeah, but what's the fun in doing it that way? Cheers, tedd $value = trim($value, chr(32) . chr(160)); Cookie for me? :) -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] First stupid post of the year.
On Jan 2, 2008 12:58 PM, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, January 2, 2008 2:09 pm, tedd wrote: At 1:25 PM -0600 1/2/08, Jack Mays wrote: On Jan 2, 2008 1:34 PM, tedd [EMAIL PROTECTED] wrote: from this: nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp; to this A Read the docs for trim, you can't use it inline with other functions, it will not trim the input. you have to seperate it out, e.g.: $submit = str_replace('nbsp;','',$submit); $submit = trim($submit); But, that still doesn't work. Go from here: nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp; to here: A Works for me: [EMAIL PROTECTED] ~/cd $ php -a Interactive mode enabled ?php $a = 'nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp;'; $b = str_replace('nbsp;', '', $a); echo b: $b\n\n; $c = trim($b); echo c: $c\n\n; ? b:A c: A [EMAIL PROTECTED] ~/cd $ -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php OKAY. Let's clarify. Here's the string in HTML: nbsp; nbsp; nbsp; nbsp;Anbsp; nbsp; nbsp; nbsp; The browser then passes it to GET/POST. It decodes the entities, and then urlencodes them. Now it looks like this: %a0%20%a0%20%a0%20%a0A%a0%20%a0%20%a0%20%a0 Then PHP receives it, urldecodes the string, then stuffs it inside $_POST, $_GET, $_REQUEST, etc. Now it's like this: A $_POST['submit'] == ' A ' // TRUE. ... *pokes my solution*... $value = trim($value, chr(32) . chr(160)); -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable substitution
On Jan 1, 2008 2:17 PM, jekillen [EMAIL PROTECTED] wrote: Hello again; I have two variables declared in the global scope of a script. $string_a = 'stuff $string_b and more stuff'; $string_b = ''; One is a string with a reference for substitution to the other string which is empty. In the processing body of the script are if/if else blocks. In these blocks I want to use $string_a and set $string_b to a value if( condition) { $string_b = 'by the way;';... etc so $string_a should read: stuff and by the way; and more stuff But this substitution will not take place in the context of the else if block. I do not want to write $string_a in at least 5 different if else blocks because it is about 10 lines intended to be an e-mail message body - !SPAM. this script is used to process data sent from a link in another e-mail message used to validate and e-mail address. Q: Is there a way to get the substitution to take place here? (by reference, maybe?) Thank you in advance for info Jeff K -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hmmm... will this work? function get_string_a() { global $string_b; return stuff $string_b and more stuff; } -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparison Problems with 5.2.5
On Dec 30, 2007 8:04 AM, Silvio Porcellana [EMAIL PROTECTED] wrote: Magnus Anderson wrote: ...snip... This will not work (I expect this to work since _USER['level'] is 5) if($_USER['level'] = 5) Try if($_USER['level'] = 5) maybe it helps ('=' is used when assigning values in an hash, maybe you are triggering something strange...) -- Antinori and Partners - http://www.antinoriandpartners.com Soluzioni web - da professionisti -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think it needs to be = (greater than or equal to) or = (less than or equal to). -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: [PHP] Using PHP to remove certain number of bytes from file
On Dec 30, 2007 11:26 AM, Robert Cummings [EMAIL PROTECTED] wrote: On Sun, 2007-12-30 at 14:14 -0500, Benjamin Darwin wrote: Maybe one of these days I'll remember to actually reply to the list the first time. -- Forwarded message -- From: Benjamin Darwin [EMAIL PROTECTED] Date: Dec 30, 2007 2:12 PM Subject: Re: [PHP] Using PHP to remove certain number of bytes from file To: Scott Wilcox [EMAIL PROTECTED] Try this: $file_data = file_get_contents('filename', false, null, 230); file_put_contents('filename', $file_data); I don't suggest this route with files that are in the hundreds of megs :) But admittedly, it's the simplest solution for small files. Also, can't use it if you're stuck with PHP 4 since it doesn't support file_put_contents(). PHP4 is dead now anyways, supposedly, so I read someplace ;) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php 30 seconds alternative: ?php $fh = fopen($file, 'rb'); $f2 = fopen('temp', 'wb'); fseek($fh, 230); do { fwrite($f2, fread($fh, 4069)); } while (!feof($fh); fclose($fh); fclose($f2); rename('temp', $file); ? -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSS
On Dec 26, 2007 12:03 PM, Mad Unix [EMAIL PROTECTED] wrote: Am facig problem with XSS cross Site scripting general on our web site, and i think its a coding issue since our dedicated server run Linux with apache mysql and php... any recommendation to resolve this issue -- madunix Of course! -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] loadHTML()
That's because it's not proper XHTML: br should be br /. On Dec 24, 2007, at 6:03 PM, M5 [EMAIL PROTECTED] wrote: Just getting into DOMDocument()... I'm loading an HTML page and trying to extract certain bits of text. Just one problem: loadHTML() seems to ignore orphan tags like 'br'. For example, in the following HTML: div class=textSome text is here. br New line. br Another new line. /div div class=textSome text is here. br New line. br Another new line. /div div class=textSome text is here. br New line. br Another new line. /div If I run the above HTML through: $nodes = $table-getElementsByTagName(*); I only get three nodes that I can iterate through (div). What I want to do is split/explode the three lines within each div, but when I look at the nodeValue of each node, it only shows something like Some text is here. New line. Another new line. Any ideas? ...Rene -- 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] loadHTML()
Actually, never mind. It does not have to be valid to work. On Dec 24, 2007, at 6:15 PM, Casey [EMAIL PROTECTED] wrote: That's because it's not proper XHTML: br should be br /. On Dec 24, 2007, at 6:03 PM, M5 [EMAIL PROTECTED] wrote: Just getting into DOMDocument()... I'm loading an HTML page and trying to extract certain bits of text. Just one problem: loadHTML () seems to ignore orphan tags like 'br'. For example, in the following HTML: div class=textSome text is here. br New line. br Another new line. /div div class=textSome text is here. br New line. br Another new line. /div div class=textSome text is here. br New line. br Another new line. /div If I run the above HTML through: $nodes = $table-getElementsByTagName(*); I only get three nodes that I can iterate through (div). What I want to do is split/explode the three lines within each div, but when I look at the nodeValue of each node, it only shows something like Some text is here. New line. Another new line. Any ideas? ...Rene -- 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] Simple RegEx question
On Dec 24, 2007, at 7:34 PM, M5 [EMAIL PROTECTED] wrote: I'm learning regular expressions, and trying to figure out what's possible and what's not. Any ideas of how to create a preg_match expression to parse following three lines: Calgary, AB T2A6C1 Toronto, ON T4M 0B0 Saint John, NBE2L 4L1 ...such that it splits each line into City, Province and Postalcode (irrespective of occasional white space), e.g.: Array ( [city]= Calgary, [prov]= AB, [postal]= T2A 6C1 ) Array ( [city]= Toronto, [prov]= ON, [postal]= T4M 0B0 ) Array ( [city]= Saint John, [prov]= NB, [postal]= E2L 4L1 ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Try this: $places = array(); $lines = explode(\n, $toparse); foreach ($lines as $i = $line) list($places[$i]['city'], $places[$i]['prov'], $places[$i] ['postal']) = explode(' ', $line, 3);' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple RegEx question
On Dec 24, 2007, at 7:59 PM, Casey [EMAIL PROTECTED] wrote: On Dec 24, 2007, at 7:34 PM, M5 [EMAIL PROTECTED] wrote: I'm learning regular expressions, and trying to figure out what's possible and what's not. Any ideas of how to create a preg_match expression to parse following three lines: Calgary, AB T2A6C1 Toronto, ON T4M 0B0 Saint John, NBE2L 4L1 ...such that it splits each line into City, Province and Postalcode (irrespective of occasional white space), e.g.: Array ( [city]= Calgary, [prov]= AB, [postal]= T2A 6C1 ) Array ( [city]= Toronto, [prov]= ON, [postal]= T4M 0B0 ) Array ( [city]= Saint John, [prov]= NB, [postal]= E2L 4L1 ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Try this: $places = array(); $lines = explode(\n, $toparse); foreach ($lines as $i = $line) list($places[$i]['city'], $places[$i]['prov'], $places[$i] ['postal']) = explode(' ', $line, 3);' I'm very sorry about that, Ive been wrong all week! It doesn't parse Saint John correctly :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending SMS via PHP
On Dec 22, 2007 9:00 PM, AmirBehzad Eslami [EMAIL PROTECTED] wrote: Hi, How can i send SMS messages via PHP? How can i set SMS-headers (UDH)? Does anyone know some article/class/package about this issue? Thank you in advance, -b You could send emails. http://en.wikipedia.org/wiki/SMS_gateways#Email_to_SMS -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a bit OT - Does XMLHTTP work with Digest Authentication?
On Dec 19, 2007 10:24 AM, Shu-Wai Chow [EMAIL PROTECTED] wrote: I've been searching all over MSDN for this info, but can't find anything. I have a script under a directory protected by HTTP Digest authentication. This is an Apache server on Linux. When I try to access the script through ajax using the XMLHttpRequest object, everything is fine in all browsers including IE 7, which uses XMLHttpRequest. In IE 6 and below, using Microsoft.XMLHTTP, the connection fails. HttpStatus returns an odd number (it's five digits) and the responseText and responseXML properties are empty. I'm embedding the username and password according to the open() method spec: xmlhttp.open('GET', 'script/path', true, 'username', 'password'); I originally wrote the responses and checks in PHP using the example given in the HTTP Authentication section of the manual, but switched to .htaccess, thinking it was a problem. It didn't help. However, when I switched the AuthType to Basic, IE 6 worked fine. Does anyone have any experience using XMLHTTP with digest authentication that can shed some light on this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I've run into this problem before... Try searching Google with the five-digit status code. It's one of Microsoft's non-standard codes... -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP translation needed
On Dec 17, 2007 7:06 PM, Grace Shibley [EMAIL PROTECTED] wrote: Hi Everyone, We have an encryption function that was written in another language that we needed translated to PHP. Here's the function: function rc4 pText, pKey -- initialize repeat with i = 0 to 255 put i into S1[i] end repeat put 0 into i repeat with n = 0 to 255 add 1 to i if i length(pkey) then put 1 into i put chartonum(char i of pKey) into S2[n] end repeat put 0 into j repeat with i = 0 to 255 put (j + S1[i] + S2[i]) mod 256 into j put S1[i] into temp put S1[j] into S1[i] put temp into S1[j] end repeat -- encrypt/decrypt put 0 into i ; put 0 into j repeat for each char c in pText put chartonum(c) into tChar put (i + 1) mod 256 into i put (j + S1[i]) mod 256 into j put S1[i] into temp put S1[j] into S1[i] put temp into S1[j] put (S1[i] + S1[j]) mod 256 into t put S1[t] into K put numtochar(tChar bitXor K) after tOutput end repeat return tOutput end rc4 Can anyone help us with this? We don't mind paying via PayPal :) Thanks! grace function rc4($pText, $pKey) { // initialize $S1 = range(0, 255); $S2 = array(); $i = 0; for ($n=0; $n=255; $n++) { $i++; if ($i strlen($pkey)) $i = 1; $S2[] = ord($pKey[$i]); } $j = 0; for ($i=0; $i=255; $i++) { $j = ($j + $S1[$i] + $S2[$i]) % 256; $temp = $S1[$i]; $S1[$i] = $S1[$j]; $S1[$j] = $temp; } // encrypt/decrypt $i = $j = 0; $tOutput = ''; foreach (str_split($pText) as $c) { $tChar = ord($c); $i = ($i+1) % 256; $j = ($j+$S1[$i]) % 256; $temp = $S1[$i]; $S1[$i] = $S1[$j]; $S1[$j] = $temp; $t = ($S1[$i] + $S1[$j]) % 256; $K = $S1[$t]; $tOutput .= chr($tChar ^ $K); } return $tOutput; } I don't know what language this is. I'm curious -- what is it? It might not work; it's untested except for syntax errors. [EMAIL PROTECTED] ;] -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing text into images, and setting text size
Try imagettftext(). On Dec 16, 2007 5:59 PM, Dave M G [EMAIL PROTECTED] wrote: PHP List, I've been able to write text into an image using the default fonts available, with this command: ImageString($image, 5, $x - 20,$y-10, $text, $textColour); The problem is that the font that is identified by the index 5 is too small. But it seems that it can't be scaled in any way. So I thought I would try to specify a font and try something like this: $font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf'; $imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text); But I'm clearly not doing things quite right, and I have some questions: 1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts directory. But specifying it doesn't seem to work. How do I get the system to find the font? 2. I need the scripts I'm writing to be portable, so can I be sure of what fonts will be available, and will I be able to locate them? 3. I'm not really concerned about what font it is, just that it's large and readable. If there are other options than what I've explored here, then I would be open to those too. Thank you for any advice. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php code compiles, produces good html output, but crashes when put through browser
Comment out all Javascript. On Dec 15, 2007, at 2:00 PM, Daniel Brown [EMAIL PROTECTED] wrote: On Dec 15, 2007 4:55 PM, Mary Anderson [EMAIL PROTECTED] wrote: My code http://demog.berkeley.edu/~maryfran/memdev/get_data_set.php Mary, Can you provide the actual code for the page? None of us can really help you out too much without seeing more than a blank page. -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. -- 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] php code compiles, produces good html output, but crashes when put through browser
On Dec 15, 2007 11:27 PM, Jochem Maas [EMAIL PROTECTED] wrote: Casey wrote: Comment out all Javascript. Casey - exactly how would javascript being causing a webserver to segfault in this context??? On Dec 15, 2007, at 2:00 PM, Daniel Brown [EMAIL PROTECTED] wrote: On Dec 15, 2007 4:55 PM, Mary Anderson [EMAIL PROTECTED] wrote: My code http://demog.berkeley.edu/~maryfran/memdev/get_data_set.php Mary, Can you provide the actual code for the page? None of us can really help you out too much without seeing more than a blank page. -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe I didn't read well enough, but if the PHP produces proper HTML on the command line, shouldn't it work in the browser too? My logic is that if the title displays, then the browser hangs, it should be something on the client-side, right? Maybe I'm not thinking clearly. I worked all day today.. -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] zlib and fopen and stream_filter_append, prebuffer read errors help
On Dec 13, 2007 7:44 AM, Bob Sabiston [EMAIL PROTECTED] wrote: On Dec 12, 2007, at 7:20 PM, Casey wrote: Try gzuncompress(); Correct me if I'm wrong, but isn't gzuncompress used for 'gzip' files? Although they both use the same compression, gzip is specific to files and has header information not present in straight zlib data. And as I've mentioned, this is a normal file, not compressed -- I'm just trying to read and decompress pieces of data within the file, which according to the documentation is something zlib does. I assume that most people use these functions for entire files, but surely someone has used it the other way as well? Thanks for any info. Bob Zlib compression is what's used in Gzip. Just try it ;) $uncompressed = gzuncompress(file_get_contents(binaryfile.ext)); -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] zlib and fopen and stream_filter_append, prebuffer read errors help
Try gzuncompress(); On Dec 12, 2007, at 1:03 PM, Bob Sabiston [EMAIL PROTECTED] wrote: On Dec 12, 2007, at 2:31 PM, Richard Lynch wrote: On Wed, December 12, 2007 11:28 am, Bob Sabiston wrote: I'm trying to read some zlib-compressed data from a regular binary file. When I try to attach the zlib compression filter, I am getting an error: something about how the prebuffered data didn't work with the filter and so the filter wasn't added to the filter chain. I looked and found a way to turn off buffering for stream *writes*, but not for stream reads. Can anyone help with ideas for why this isn't working? I posted questions to comp.lang.php and received no response. If all else fails, you could just not use the fancy-pants new stream and filter functions, and just use http://php.net/zlib directly on the file. Sorry Richard for the double mail, I didn't have the list cc'd before... How could I do that? I thought the only way to use zlib in PHP was through the stream functions. It's also possible your zlib file is just plain corrupt, and neither will work... But I am getting the error before I start to read -- it is not a zlib 'file', it is a stretch of data within an ordinary file that has been compressed with zlib. Thanks Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session call not creating file in session_save_path - perms? (newbie)
Read manual please. http://us.php.net/session_save_path On Dec 12, 2007 9:27 PM, Robert Erbaron [EMAIL PROTECTED] wrote: OK, I've read every message on the list for the last year that contains 'sessions'. I've read through (bleary eyed, admittedly) http://us2.php.net/session. And I swear, honest, that I had this working on another box (which is no longer available to me.) I've checked phpinfo - session support is on, session.use_cookie is On. PHP 5.1.6 or thereabouts. ?php session_start(); session_save_path('/home/rob//Sites/zphpsessions'); echo 'sessionid:'.session_id().':br'; echo 'save path:'.session_save_path().':br'; $ip = ' '.$_SERVER['REMOTE_ADDR']; echo '$ip is:'.$ip.':br'; $_SESSION['ipx']=$ip; echo 'ipx (session) is:'.$_SESSION['ipx'].':br'; if (!isset($_SESSION['ipx'])) echo 'whoa nelly'; echo 'This is the main page'; ? Output looks like this: sessionid:8klvud4o186lme7n6v84lhfjl2: save path:/home/rob/Sites/zphpsessions: $ip is: 127.0.0.1: ipx (session) is: 127.0.0.1: This is the main page No data is being dumped into /home/rob/Sites/zphpsessions. The best I can guess is permissions. If I change save_path to /tmp, no difference - still nothing being written there. I bet I'm doing something ignorant about apache users or something, huh? -- RE, Chicago -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Memory Leak
On Dec 6, 2007, at 3:15 PM, Sascha Braun [EMAIL PROTECTED] wrote: Hi Everybody, I have a couple of foreach loops which are ending in a for loop, which causes the apache to consume the complete memory of the server system the php engine is running on. The nesting level is at round about three and looking like that: $num_new = 4; if (is_array($array)) { foreach ($array as $key = value) Typo on above line? { if ($value['element'] == 'test1') { foreach ($value['data'] as $skey = $svalue) { echo $svalue; } } elseif ($value['element'] == 'test2') { foreach ($value['data'] as $skey = $svalue) { echo $svalue; } } if ($num_new 0) { // this part causes the memory leak for ($i = 0; $i $num_new; $i++) { echo sgasdgga; } } } } I dont know if the above code is causing the memory leak the source is a little more complex, if nessessary I will provide some more code, Thank you! I hope for a solution -- 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