Re: [PHP] Re: Are PHP5 features worth it?

2006-12-21 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-21 03:33:36 +0100:
> On Wednesday 20 December 2006 13:37, Roman Neuhauser wrote:
> > # [EMAIL PROTECTED] / 2006-12-19 19:05:23 +0100:

> >> What major compelling reasons do I have to start using exceptions and
> >> OOP-5?

> >> What about performance?
> > 
> > Did you measure the performance impact of all those if/else's?
> > 
> > Exceptions are a special channel for errors, so your question is kind of
> > like "is stderr any good? what about performance?"
> >  
> If two different ways of doing the same thing seem very similar, performance
> may help me choose. It's true that I don't know anything about the speed of
> all my nested if/elses, but that's not necessarily relevant if others can
> tell me that exceptions are always hopelessly slow.

They won't be able to tell you what impact using exceptions would have
on your code.

> > How about iterators? You can have objects that look like arrays yet they
> > take much less memory:
> > 
> >     $rs = $db->query($select); # query the db
> >     foreach ($rs as $row) { # fetch the row
> >         whatever($row);
> >     }
> 
> "takes much less memory" is exactly the kind of advice I'm looking for.

Don't get too excited, please. I'm not promising you'll be able to
squeeze your CMS into 640KB.

You're concentrating on the wrong thing. Development time is way more
expensive than cpu power. I like to use typed parameters and access
specifiers because they're a very concise form of documentation, and
this documentation never lags behind the code! I like to use exceptions,
because they allow me to write safer and more elegant code. Performance
benefits? Sure, they're development boosters.

What about performance? When PHP 4.0 came out, CPUs had 500MHz (IIRC),
when PHP 5.2 came out, CPUs are at 4GHz. There go your microbenchmarks.

> I've found very few usable guides to such optimizations. Could you
> possibly give me a specific example of an array and a similar object
> with this great difference in memory consumptions?

Anywhere you can replace a sufficiently large aggregate structure with
an iterator. They can be used as generators (c. f. python 2.5), and I'd
call e. g. DirectoryIterator from SPL a generator.


-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Poping array which has the matching value

2006-12-21 Thread Sumeet

Che Hodgins wrote:

Leo,

$letters = array('a', 'b', 'c', 'd', 'e', 'f');
$key = array_search('c', $letters);


you can also try

unset( $letters[$key] );

sumeet


$value = array_splice($letters, $key, 1);

$value[0] will contain 'c'
$letters will contain Array ( [0] => a [1] => b [2] => d [3] => e [4] => 
f )


regards,
Che

On 12/21/06, Leo Liu <[EMAIL PROTECTED]> wrote:

Hi,

I wanted to search through the array and pop out the value which match 
my search criteria. For example


If array has {a,b,c,d,e,f}

I wanna search for "c" and once I found it, took it out from the array.

So the result of the array after operation will be

{a,b,d,e,f}

If I do array_pop(); function it will only pop the last element inside 
the array and the array will become


{a,b,c,d,e}

Anyway to search the desire element inside the array and took it out 
from the array?


Regards,
Leo

Reality starts with Dream

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com






--
Thanking You

Sumeet Shroff
http://www.prateeksha.com
Web Designers and PHP / Mysql Ecommerce Development, Mumbai India

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



Re: [PHP] Poping array which has the matching value

2006-12-21 Thread Jochem Maas
Leo Liu wrote:
> Hi,
> 
> I wanted to search through the array and pop out the value which match my 
> search criteria. For example
> 
> If array has {a,b,c,d,e,f}
> 
> I wanna search for "c" and once I found it, took it out from the array.

here is a 'solution', you may not understand it fully - in which case the manual
is your best friend - he has unlimited patience when explaining and he is a very
gifted teacher (he managed to knock this stuff into my thick skull ;-)

$haystack = range("a","f");
$needle   = "c";
while (($key = array_search($needle, $haystack, true)) !== false)
unset($haystack[$key]);

$haystack = array_values($haystack);

> 
> So the result of the array after operation will be
> 
> {a,b,d,e,f}
> 
> If I do array_pop(); function it will only pop the last element inside the 
> array and the array will become
> 
> {a,b,c,d,e}
> 
> Anyway to search the desire element inside the array and took it out from the 
> array?
> 
> Regards,
> Leo
>  
> Reality starts with Dream

No It Does Not. Reality is what becomes apparent when you you stop judging,
stop thinking and stop dreaming. That being so we're all sound asleep.

now I'm back off to dreaming about swedish triplets driving around in an Audi 
RS4. :-P

> 
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 

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



[PHP] Creating multidimensional array

2006-12-21 Thread Yonatan Ben-Nes

Hi all,

I got a problem with creating a multidimensional array which it's size is
unknown.
I already made it work like this (example):
= 0; $i--) {
 $array_keys_string_representation .= '["'.$array[$i].'"]';
}

eval('$new_array'.$array_keys_string_representation.'["node_title"] =
"string value";');
?>

The problem is that I don't like using eval() cause it's slow &
insecure.

I want to do something like this (doesn't work):
= 0; $i--) {
 $array_keys_string_representation .= '["'.$array[$i].'"]';
}

$new_array.$array_keys_string_representation.'["node_title"] = "string
value";
?>

Anyone got any idea how can I build such an array without eval()?

Thanks a lot in advance,
 Ben-Nes Yonatan


Re: [PHP] Creating multidimensional array

2006-12-21 Thread Jochem Maas
you can do this with a bit of reference magic...



there might a cleaner/better way - if anyone can correct me I'd
be glad to learn :-)

Yonatan Ben-Nes wrote:
> Hi all,
> 
> I got a problem with creating a multidimensional array which it's size is
> unknown.
> I already made it work like this (example):
>  $array = array('six','five','four','three','two','one');
> 
> for ($i = count($array)-1; $i >= 0; $i--) {
>  $array_keys_string_representation .= '["'.$array[$i].'"]';
> }
> 
> eval('$new_array'.$array_keys_string_representation.'["node_title"] =
> "string value";');
> ?>
> 
> The problem is that I don't like using eval() cause it's slow &
> insecure.
> 
> I want to do something like this (doesn't work):
>  $array = array('six','five','four','three','two','one');
> 
> for ($i = count($array)-1; $i >= 0; $i--) {
>  $array_keys_string_representation .= '["'.$array[$i].'"]';
> }
> 
> $new_array.$array_keys_string_representation.'["node_title"] = "string
> value";
> ?>
> 
> Anyone got any idea how can I build such an array without eval()?
> 
> Thanks a lot in advance,
>  Ben-Nes Yonatan
> 

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



Re: [PHP] Creating multidimensional array

2006-12-21 Thread Robert Cummings
On Thu, 2006-12-21 at 14:54 +0200, Yonatan Ben-Nes wrote:
> Hi all,
> 
> I got a problem with creating a multidimensional array which it's size is
> unknown.
> I already made it work like this (example):
>  $array = array('six','five','four','three','two','one');
> 
> for ($i = count($array)-1; $i >= 0; $i--) {
>   $array_keys_string_representation .= '["'.$array[$i].'"]';
> }
> 
> eval('$new_array'.$array_keys_string_representation.'["node_title"] =
> "string value";');
> ?>



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.  |
`'

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



[PHP] um ... arrays

2006-12-21 Thread Steven Macintyre
Hi ... 

I have the following;

   $files = array();
   $curimage=0;
   if($handle = opendir($dirname)) {
   while(false !== ($file = readdir($handle))){
   if(eregi($pattern, $file)){
$filedate=date ("M d, Y H:i:s",
filemtime($file));
if(substr($file,-5)=='t.jpg') {
 echo 'leftrightslide[' . $curimage .']=\'\';' . "\n";
 }
 $curimage++;
   }
   }

   closedir($handle);
   }
   shuffle($files);
   return($files);

now ... why does files not get shuffled?

Is that not the purpose of that function ?

Steven

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



Re: [PHP] um ... arrays

2006-12-21 Thread Stut

Steven Macintyre wrote:

I have the following;

   $files = array();
   $curimage=0;
   if($handle = opendir($dirname)) {
   while(false !== ($file = readdir($handle))){
   if(eregi($pattern, $file)){
$filedate=date ("M d, Y H:i:s",
filemtime($file));
if(substr($file,-5)=='t.jpg') {
 echo 'leftrightslide[' . $curimage .']=\'\';' . "\n";
 }
 $curimage++;
   }
   }

   closedir($handle);
   }
   shuffle($files);
   return($files);

now ... why does files not get shuffled?

Is that not the purpose of that function ?


1) Nowhere in that while loop do you add elements to the $files array.
2) Yes, that is what the shuffle function does, but it will have no 
effect on an empty array.


-Stut

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



RE: [PHP] um ... arrays

2006-12-21 Thread Edward Kay
$files is empty - nowhere in your while loop do you add any data to it.

My guess is your question is really 'Why are my images displayed in the same
order as the directory?'. This is because you're displaying them at the same
time as reading the dir. To randomise the order, add all the file names to
the $files array, shuffle($files) and then have a foreach loop to iterate
over $files and output the HTML to display them.

Edward

> -Original Message-
> From: Steven Macintyre [mailto:[EMAIL PROTECTED]
> Sent: 21 December 2006 13:45
> To: php-general@lists.php.net
> Subject: [PHP] um ... arrays
>
>
> Hi ...
>
> I have the following;
>
>$files = array();
>$curimage=0;
>if($handle = opendir($dirname)) {
>while(false !== ($file = readdir($handle))){
>if(eregi($pattern, $file)){
>   $filedate=date ("M d, Y H:i:s",
> filemtime($file));
>   if(substr($file,-5)=='t.jpg') {
>  echo 'leftrightslide[' . $curimage .']=\' href="?file='.$file.'&c='.$cat.'"> style="border:1px solid #bb3621">\';' . "\n";
>}
>  $curimage++;
>}
>}
>
>closedir($handle);
>}
>shuffle($files);
>return($files);
>
> now ... why does files not get shuffled?
>
> Is that not the purpose of that function ?
>
> Steven
>
> --
> 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



[PHP] random selection from each subfolder

2006-12-21 Thread Steven Macintyre
Ok ... previous problem sorted ... now onto the next ...

The client wants the following; 

A scroll bar with 3 random thumbs from each subdirectory in the /images/
folder

I was thinking ...

Going into each folder, getting files, pushing into an array - shuffling
array, taking first three items and combine it to a "master" array and use
that ...

Good thinking? Better suggestions?



Kind Regards,


Steven Macintyre
http://steven.macintyre.name
--

http://www.friends4friends.co.za

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



[PHP] MS Outlook 2003 Options

2006-12-21 Thread Ray Hauge
Okay, this doesn't have to do with PHP directly, but it does have to do
with this list.  I'm using MS Outlook 2003.  My company has an exchange
server, and the Evolution OWA client doesn't work well enough for all
the calendaring stuff I have to do.  So, I was wondering if anyone else
out there has run into the problems I am having.

 

First, and foremost, Outlook doesn't thread messages very well.  Are
there any plug-ins or options that can be set to get my PHP folder to
display a proper threaded view?  I used to have this in Kmail, and I
desperately miss it.

 

Second is bottom posting.  Is there any way to get Outlook to put my
reply at the bottom of the page?  Again with the Kmail :-)

 

I've been looking for information on these for the past hour or so, but
my searching powers aren't working Damn kryptonite!

 

 

Thanks!

 

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 



Re: [PHP] Are PHP5 features worth it?

2006-12-21 Thread tg-php
Ha!  Mine too!   How long before this secret gets out and our apps all start 
imploding??

Technically this is true.  You can't do AJAX with PHP4.  Or PHP5.  Not the 
"AJAX" part at least, since it's all handled in Javascript.What gets 
returned to the AJAX app and what it interacts with on the web server can very 
well be PHP of any flavor, or any other web app scripting language or even just 
regular HTML I suppose.

I love statements like Bernhard's.

-TG

= = = Original message = = =

At 3:14 PM +0100 12/20/06, Bernhard Zwischenbrugger wrote:
>
>"AJAX" Webapplications are not possible in PHP4.

Please be very, very quite, my PHP4 web "AJAX" Web applications don't 
know that and I don't want them revolting.

tedd

-- 
---
http://sperling.com  http://ancientstones.com  http://earthstones.com


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] parsing objects

2006-12-21 Thread Marcus
Hello

I have a soap call that returns something like;

Result from a print_r();

stdClass Object ( [getCategoryTreeReturn] => Array ( [0] => stdClass Object
( [iId] => 1 [sName] => Cars & Motorbikes [iParentId] => 0 [iTreeCount] =>
114302 [iLocalCount] => 0 [aSubCats] => Array ( [0] => stdClass Object (
[iId] => 2 [sName] => Car Electronics [iParentId] => 1 [iTreeCount] => 0
[iLocalCount] => 0 ) [1] => stdClass Object ( [iId] => 5 [sName] => Car
Accessories [iParentId] => 1 [iTreeCount] => 57160 [iLocalCount] => 57142 )
[2] => stdClass Object ( [iId] => 16 [sName] => Motorcycles [iParentId] => 1
[iTreeCount] => 11 [iLocalCount] => 0 )

I need to convert that to a multidimensional array to link ID's to Parent
ID's. I have created a function which recursively scans the result variable.
It writes the rows to a temporary file for later fetching, but it is
somewhat slow. Can i maintain those recursive seek to an array. As function
is being called inside and inside, i can not return a proper value. Is there
any way to maintain those rows without writing to tmp.


The function is :

--- BEGIN ---

function deepseek($val) {

foreach ($val as $key => $value) {

if (is_object($value)) {
$newarr = get_object_vars($newarr);
foreach ($newarr as $key2 => $value2) {
deepseek($value2);
}
}

if (is_array($value)) {

foreach ($value as $key2 => $value2) {
deepseek($value2);
}
}

if (!is_array($value) AND !is_object($value)) {

if ($key == "iParentId" OR $key == "sName" OR $key == "iId") {

$output .= "$value-";

}

if ($key == "iTreeCount") {
$handle = fopen("tmp/tmp","a");
fwrite($handle,$output."\n");
fclose($handle);

unset($output);

}


}

}


}
--- END ---

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



Re: [PHP] MS Outlook 2003 Options

2006-12-21 Thread Stut

Ray Hauge wrote:

Okay, this doesn't have to do with PHP directly, but it does have to do
with this list.  I'm using MS Outlook 2003.  My company has an exchange
server, and the Evolution OWA client doesn't work well enough for all
the calendaring stuff I have to do.  So, I was wondering if anyone else
out there has run into the problems I am having.

First, and foremost, Outlook doesn't thread messages very well.  Are
there any plug-ins or options that can be set to get my PHP folder to
display a proper threaded view?  I used to have this in Kmail, and I
desperately miss it.

Second is bottom posting.  Is there any way to get Outlook to put my
reply at the bottom of the page?  Again with the Kmail :-)

I've been looking for information on these for the past hour or so, but
my searching powers aren't working Damn kryptonite!


Ok, first of all this couldn't have less to do with PHP no matter how 
you try to frame it. However, I do have some sympathy for your 
situation, so for the sake of the archives here's a response...


1) Use Thunderbird for mailing lists. Outlook sucks for anything 
non-enterprise.


2) I have this Gmail account purely for mailing lists. It forwards to an 
IMAP mailbox and I then use Thunderbird from work, home and laptop to 
access it. Works very well.


3) At work I am forced to use Outlook, so I use Outlook QuoteFix to, 
erm, fix the quoting in Outlook... 
http://home.in.tum.de/~jain/software/outlook-quotefix


-Stut

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



Re: [PHP] ob_start("ob_gzhandler") and error handling functions

2006-12-21 Thread IG

Hi again,

Just wandering if someone could help me on this one- I'm quite anxious 
to get something together. As I said in the last email I just want to 
use ob_start("ob_gzhandler") but it doesn't seem to work with the error 
function. I think it might be something to do with not being allowed 
within a 'callback function'- well that's what it says on the php 
manual. The thing is I'm not sure what that means, I find that section 
not particularly clear. Please can someone help!


IG wrote:

Hi,

I include a php file at the beginning of every web page in this site. 
This include file has an error handling function and starts output 
buffering...


// Start of Error Handler
error_reporting(E_ALL ^ E_NOTICE);
ini_set('log_errors','1');

function ErrHandler($err,$err_string='',$err_file,$err_line)
   {
   // Do error logging thang

   ob_end_clean();// Clear buffer
 include('/path/incs/errors/errors.inc');// Output friendly 
error page

   exit();
   }  
set_error_handler('ErrHandler');


// End of Error Handler

It works great and the error handler kicks in if there is an error on 
the page and outputs a friendly page instead. I really wanted to gzip 
the pages by using ob_start("ob_gzhandler") but it doesn't work. I think 
it is because of the error handler function trying to clear the buffer 
(see the line ob_end_clean() which I assume becomes 
ob_end_clean("ob_gzhandler") ). It says on the php functions page- 
*ob_start()* may not be called from a callback function. If you call 
them from callback function, the behavior is undefined. If you would 
like to delete the contents of a buffer, return "" (a null string) from 
callback function.


As I am new to this- I don't really understand what it is trying to get 
at. Is there a way of me using my error handler and evoking the 
ob_start("ob_gzhandler") ?


Thanks.

Ianob_




|ob_start("ob_gzhandler");|



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



Re: [PHP] ob_start("ob_gzhandler") and error handling functions

2006-12-21 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-20 14:12:11 +:
> I include a php file at the beginning of every web page in this site. 
> This include file has an error handling function and starts output 
> buffering...
> 
> // Start of Error Handler
> error_reporting(E_ALL ^ E_NOTICE);
> ini_set('log_errors','1');
> 
> function ErrHandler($err,$err_string='',$err_file,$err_line)
>{
>// Do error logging thang
> 
>ob_end_clean();// Clear buffer
>   
>include('/path/incs/errors/errors.inc');// Output friendly error 
> page
>exit();
>}   
> 
> set_error_handler('ErrHandler');
> 
> // End of Error Handler
> 
> It works great and the error handler kicks in if there is an error on 
> the page and outputs a friendly page instead. I really wanted to gzip 
> the pages by using ob_start("ob_gzhandler") but it doesn't work. I think 
> it is because of the error handler function trying to clear the buffer 
> (see the line ob_end_clean() which I assume becomes 
> ob_end_clean("ob_gzhandler") ). It says on the php functions page- 
> *ob_start()* may not be called from a callback function. If you call 
> them from callback function, the behavior is undefined. If you would 
> like to delete the contents of a buffer, return "" (a null string) from 
> callback function.
> 
> As I am new to this- I don't really understand what it is trying to get 
> at. Is there a way of me using my error handler and evoking the 
> ob_start("ob_gzhandler") ?

I don't use this stuff myself, but it looks like the second half
of this comment might be applicable to you:
http://cz2.php.net/manual/en/function.ob-end-clean.php#71092

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



[PHP] Test

2006-12-21 Thread Ray Hauge

Hey guys,

I just switched email accounts, so I'm testing to make sure that the 
subscription worked.


Thanks,
Ray

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



[PHP] Test

2006-12-21 Thread Ray Hauge

Hello everyone,

I just switched to one of my personal accounts.  Just making sure that 
the subscription went well.


Thanks,
Ray

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



Re: [PHP] Are PHP5 features worth it?

2006-12-21 Thread Bernhard Zwischenbrugger
Hi

You can make AJAX Applications without XML (AJWOX). You can also make
Synchronous AJAX without using the XMLHttpRequest Object.
You can call it SJWOX (synchronous javascript without XML).

The thing I like is, that character encoding is correct if you use XML
for sending data to the server. Wrong encoded messages are not accepted.

To make your own XML parser is not at all easy.
Think about a simple message like:


Ü is not Ü

(Parser must report an error)

Bernhard

Am Donnerstag, den 21.12.2006, 10:55 -0500 schrieb
[EMAIL PROTECTED]:
> Ha!  Mine too!   How long before this secret gets out and our apps all start 
> imploding??
> 
> Technically this is true.  You can't do AJAX with PHP4.  Or PHP5.  Not the 
> "AJAX" part at least, since it's all handled in Javascript.What gets 
> returned to the AJAX app and what it interacts with on the web server can 
> very well be PHP of any flavor, or any other web app scripting language or 
> even just regular HTML I suppose.
> 
> I love statements like Bernhard's.
> 
> -TG
> 
> = = = Original message = = =
> 
> At 3:14 PM +0100 12/20/06, Bernhard Zwischenbrugger wrote:
> >
> >"AJAX" Webapplications are not possible in PHP4.
> 
> Please be very, very quite, my PHP4 web "AJAX" Web applications don't 
> know that and I don't want them revolting.
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
> 
> ___
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
> 

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



Re: [PHP] Are PHP5 features worth it?

2006-12-21 Thread Robert Cummings
On Thu, 2006-12-21 at 20:02 +0100, Bernhard Zwischenbrugger wrote:
> Hi
> 
> You can make AJAX Applications without XML (AJWOX). You can also make
> Synchronous AJAX without using the XMLHttpRequest Object.
> You can call it SJWOX (synchronous javascript without XML).
> 
> The thing I like is, that character encoding is correct if you use XML
> for sending data to the server. Wrong encoded messages are not accepted.
> 
> To make your own XML parser is not at all easy.
> Think about a simple message like:
> 
> 
> Ü is not Ü
> 
> (Parser must report an error)

How does that prove it is difficult? XML parser is easy, tedious, but
easy.

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.  |
`'

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



Re: [PHP] Binary Config file: Protect script(s): Powered-by logo: How to?

2006-12-21 Thread Wonderskill

I have found the solution to the Statdaus Download Center Lite or the
config.dat.php file people have been talking about.

If you want to know what the config file is doing create a php file and put
it in the main directory:

= 0 ; $o--)
  {
  $c_var += ${$tplt}[$n][$o] * pow(2, $o);
  }
  $img_var = sprintf("%c", $c_var);
  if ($img_var == ' ') {
 $conf_var .= sprintf("%c", $str);
 $str   = '';
  } else {
  $str .= $img_var;
  }
  }
  print "$conf_var ";
?>

Then just go to this php page via browser and you will see what the config
script is writing. Problem solved.


Micky Hulse wrote:
> 
> Hey all,
> 
> A couple years ago, before I could write my own PHP, I used a 
> semi-commercial gallery script... Long story short, this gallery script 
> used a config.dat file with these contents:
> 
> 
> 
> 11001100
> 01101100
> 0100
> 10001100
> 1100
> ...
> ... (Picture 1,667 lines of this)
> ...
> 11101100
> 0100
> 00101100
> 11101100
> 0100
> 
> 
> This config file controlled how a "Powered by Company Name" was 
> displayed on the bottom of the template page.
> 
> So, if you buy the gallery script, which I did (I think I spent like 
> 20$), the "Powered by Company Name" disappears.
> 
> Since then, I have always wondered how I could do the same. I am 
> definitely not a PHP guru, but I can hold my own... There have been a 
> few scripts I have written for clients where I would have loved to 
> implement this same technique...
> 
> Recently, I re-downloaded the script and tried to break-it-down to see 
> how it works... I was able to narrow things down to a few methods, a 
> template page, and a tiny bit more of PHP script... But, it is really 
> hard to understand how this is done because the config.dat file is 
> unreadable!
> 
> Any thoughts on how I could go about doing this?
> 
> How are they making their config files (I am assuming that they 
> probably wrote a proprietary script to convert PHP code to binary 1's 
> and 0's)?
> 
> Any thoughts and/or suggestions?
> 
> If anyone is curious, I can post a bit of the code. Here is a link to 
> the gallery script:
> 
> http://www.stadtaus.com/en/php_scripts/gallery_script/
> 
> Does anyone else do something similar? I would love to see some code, 
> and/or read more about similar techniques
> 
> Thanks all,
> Cheers,
> Micky
> -- 
> ¸.·´¯`·.¸¸><(((º>`·.¸¸.·´¯`·.¸¸><º>
> ·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸><º>
> `·.¸¸><º>¸.·´¯`·.¸¸><º>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Binary-Config-file%3A-Protect-script%28s%29%3A-Powered-by-logo%3A-How-to--tf753209.html#a8013857
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



Re: [PHP] parsing objects

2006-12-21 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-12-21 18:06:28 +0200:
> Hello
> 
> I have a soap call that returns something like;
> 
> Result from a print_r();
> 
> stdClass Object ( [getCategoryTreeReturn] => Array ( [0] => stdClass Object
> ( [iId] => 1 [sName] => Cars & Motorbikes [iParentId] => 0 [iTreeCount] =>
> 114302 [iLocalCount] => 0 [aSubCats] => Array ( [0] => stdClass Object (
> [iId] => 2 [sName] => Car Electronics [iParentId] => 1 [iTreeCount] => 0
> [iLocalCount] => 0 ) [1] => stdClass Object ( [iId] => 5 [sName] => Car
> Accessories [iParentId] => 1 [iTreeCount] => 57160 [iLocalCount] => 57142 )
> [2] => stdClass Object ( [iId] => 16 [sName] => Motorcycles [iParentId] => 1
> [iTreeCount] => 11 [iLocalCount] => 0 )
> 
> I need to convert that to a multidimensional array to link ID's to Parent
> ID's.

What makes you think so?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



[PHP] Count empty array

2006-12-21 Thread Kevin Murphy

I'm wondering why this is.

$data = "";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test,Test";
$array = explode(",",$data);
$count = count($array);
$count will = 2

Why doesn't the first one give me an answer of 0 instead of 1. I know  
I could do a IF $data ==  "[empty]" and then not count if its empty  
and just set it to 0, but am wondering if there was a better way.



--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326




Re: [PHP] Count empty array

2006-12-21 Thread Robert Cummings
On Thu, 2006-12-21 at 13:31 -0800, Kevin Murphy wrote:
> I'm wondering why this is.
> 
> $data = "";
> $array = explode(",",$data);
> $count = count($array);
> $count will = 1
> 
> $data = "Test";
> $array = explode(",",$data);
> $count = count($array);
> $count will = 1
> 
> $data = "Test,Test";
> $array = explode(",",$data);
> $count = count($array);
> $count will = 2
> 
> Why doesn't the first one give me an answer of 0 instead of 1.

For the same reason the second one gives you a count of one. There are
no commas and so only one item exists. Whether that be an string with
content or the empty string itself is irrelevant.

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.  |
`'

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



Re: [PHP] Count empty array

2006-12-21 Thread Jon Anderson

Kevin Murphy wrote:

I'm wondering why this is.

$data = "";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test,Test";
$array = explode(",",$data);
$count = count($array);
$count will = 2

Why doesn't the first one give me an answer of 0 instead of 1.

This:
   var_dump(explode(',',''));
Returns this:
   array(1) {
 [0]=>
 string(0) ""
   }

And oddly, This:
   var_dump(explode(',',NULL));
Returns this:
   array(1) {
 [0]=>
 string(0) ""
   }

That explains the count() result. It seems to me that the first case 
could go either way (The part of "" before the ',' is still ""), but I'm 
unable to think of a logical reason why the second doesn't return an 
empty array.
I know I could do a IF $data ==  "[empty]" and then not count if its 
empty and just set it to 0, but am wondering if there was a better way.
$array = empty($data) ? array() : explode(',',$data);  /* That what 
you're looking for? */


jon

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



Re: [PHP] Count empty array

2006-12-21 Thread Martin Marques

On Thu, 21 Dec 2006, Kevin Murphy wrote:


I'm wondering why this is.

$data = "";
$array = explode(",",$data);
$count = count($array);
$count will = 1


$array has 1 element: An empty string.


$data = "Test";
$array = explode(",",$data);
$count = count($array);
$count will = 1


$array has 1 element: The string "Test"


$data = "Test,Test";
$array = explode(",",$data);
$count = count($array);
$count will = 2


$array has 2 elements:.

Why doesn't the first one give me an answer of 0 instead of 1. I know I could 
do a IF $data ==  "[empty]" and then not count if its empty and just set it 
to 0, but am wondering if there was a better way.


Because explode divides the string in n+1 elements, where n is the amount 
of "," (or your favorite delimiter) found in the string. So if no "," is 
found, explode will return 1 element: the whole string (even if it's 
empty).


--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
-
Lic. Martín Marqués |   SELECT 'mmarques' ||
Centro de Telemática|   '@' || 'unl.edu.ar';
Universidad Nacional|   DBA, Programador,
del Litoral |   Administrador
-
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Count empty array

2006-12-21 Thread tg-php
Not sure why it does it, but doesn't seem to be a huge deal.  I'm guessing it's 
because an empty string is still a string. It's not null.

Anyway, it's documented at:

http://us3.php.net/manual/en/function.explode.php

A user writes:

"If you split an empty string, you get back a one-element array with 0 as the 
key and an empty string for the value."

-TG

= = = Original message = = =

I'm wondering why this is.

$data = "";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test";
$array = explode(",",$data);
$count = count($array);
$count will = 1

$data = "Test,Test";
$array = explode(",",$data);
$count = count($array);
$count will = 2

Why doesn't the first one give me an answer of 0 instead of 1. I know  
I could do a IF $data ==  "[empty]" and then not count if its empty  
and just set it to 0, but am wondering if there was a better way.


-- 
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



RE: [PHP] parsing objects

2006-12-21 Thread Marcus
I need to output that as

Category:  X

   Sub-category:  1
   Sub-category: 2

..
..

linking by id's to parent id's just like in a database.



-Original Message-
From: Roman Neuhauser [mailto:[EMAIL PROTECTED]
Sent: Friday, December 22, 2006 12:18 AM
To: Marcus
Cc: php-general@lists.php.net
Subject: Re: [PHP] parsing objects


# [EMAIL PROTECTED] / 2006-12-21 18:06:28 +0200:
> Hello
>
> I have a soap call that returns something like;
>
> Result from a print_r();
>
> stdClass Object ( [getCategoryTreeReturn] => Array ( [0] => stdClass
Object
> ( [iId] => 1 [sName] => Cars & Motorbikes [iParentId] => 0 [iTreeCount] =>
> 114302 [iLocalCount] => 0 [aSubCats] => Array ( [0] => stdClass Object (
> [iId] => 2 [sName] => Car Electronics [iParentId] => 1 [iTreeCount] => 0
> [iLocalCount] => 0 ) [1] => stdClass Object ( [iId] => 5 [sName] => Car
> Accessories [iParentId] => 1 [iTreeCount] => 57160 [iLocalCount] =>
57142 )
> [2] => stdClass Object ( [iId] => 16 [sName] => Motorcycles [iParentId] =>
1
> [iTreeCount] => 11 [iLocalCount] => 0 )
>
> I need to convert that to a multidimensional array to link ID's to Parent
> ID's.

What makes you think so?

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

--
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] random selection from each subfolder

2006-12-21 Thread chris smith

On 12/22/06, Steven Macintyre <[EMAIL PROTECTED]> wrote:

Ok ... previous problem sorted ... now onto the next ...

The client wants the following;

A scroll bar with 3 random thumbs from each subdirectory in the /images/
folder

I was thinking ...

Going into each folder, getting files, pushing into an array - shuffling
array, taking first three items and combine it to a "master" array and use
that ...


As you get more & more images this will slow down, might take a while
but it will happen eventually.

Are you storing any info about images in a database (even just the
name and folder they appear in) ? You could use that to your
advantage..

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] parsing objects

2006-12-21 Thread Jochem Maas
Marcus,

some facts:

1. you CAN return 'proper' values from a recursive function call.
2. you DONT need a recursive function call to retrieve the properties
of these objects.
3. you DONT need a recursive function to build a nested data structure
(using the parent<->child ID relationship)

with regard to number 3 try having a look at the following code
snippet (I leave it as an exercise to you to figure out how to
translate it to your own situation (my example happens to
use arrays because that's how the data was retrieved from a DB,
you'll want to stick with the collection of objects you get bgack from
the SOAP call - the principle is the same):

the trick is the use of the $parents 'stack' (array) in conjunction
with references to track parents ...

// return data array (will contain a nested structure)
$data = array();

$parents = array();
while(!empty($rows)) {
foreach ($rows as $key => $row) {
// add some tree related elements with default values.
$row['selected']  = false;
$row['childselected'] = false;
$row['children']  = array();

if (!$row['parentid']) {
$dCount  = count($data);
$data[ $dCount ] = $row;
$parents[ $row['nodeid'] ] =& $data[ $dCount ];
} else if (isset($parents[ $row['parentid'] ])) {
$dCount  = count($parents[ $row['parentid'] 
]['children']);
$parents[ $row['parentid'] ]['children'][ $dCount ] = $row;
$parents[ $row['nodeid'] ] =& $parents[ $row['parentid'] 
]['children'][ $dCount ];
}
unset($rows[$key]);
}
}

Marcus wrote:
> Hello
> 
> I have a soap call that returns something like;
> 
> Result from a print_r();
> 
> stdClass Object ( [getCategoryTreeReturn] => Array ( [0] => stdClass Object
> ( [iId] => 1 [sName] => Cars & Motorbikes [iParentId] => 0 [iTreeCount] =>
> 114302 [iLocalCount] => 0 [aSubCats] => Array ( [0] => stdClass Object (
> [iId] => 2 [sName] => Car Electronics [iParentId] => 1 [iTreeCount] => 0
> [iLocalCount] => 0 ) [1] => stdClass Object ( [iId] => 5 [sName] => Car
> Accessories [iParentId] => 1 [iTreeCount] => 57160 [iLocalCount] => 57142 )
> [2] => stdClass Object ( [iId] => 16 [sName] => Motorcycles [iParentId] => 1
> [iTreeCount] => 11 [iLocalCount] => 0 )
> 
> I need to convert that to a multidimensional array to link ID's to Parent
> ID's. I have created a function which recursively scans the result variable.
> It writes the rows to a temporary file for later fetching, but it is
> somewhat slow. Can i maintain those recursive seek to an array. As function
> is being called inside and inside, i can not return a proper value. Is there
> any way to maintain those rows without writing to tmp.
> 
> 
> The function is :
> 
> --- BEGIN ---
> 
> function deepseek($val) {
> 
> foreach ($val as $key => $value) {
> 
>   if (is_object($value)) {
>   $newarr = get_object_vars($newarr);
>   foreach ($newarr as $key2 => $value2) {
>   deepseek($value2);
>   }
>   }
> 
>   if (is_array($value)) {
> 
>   foreach ($value as $key2 => $value2) {
>   deepseek($value2);
>   }
>   }
> 
>   if (!is_array($value) AND !is_object($value)) {
> 
>   if ($key == "iParentId" OR $key == "sName" OR $key == "iId") {
> 
>   $output .= "$value-";
> 
>   }
> 
>   if ($key == "iTreeCount") {
>   $handle = fopen("tmp/tmp","a");
>   fwrite($handle,$output."\n");
>   fclose($handle);
> 
>   unset($output);
> 
>   }
> 
> 
>   }
> 
> }
> 
> 
> }
> --- END ---
> 

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