php-general Digest 21 Dec 2006 21:32:18 -0000 Issue 4527

Topics (messages 246116 through 246137):

Re: Poping array which has the matching value
        246116 by: Sumeet
        246117 by: Jochem Maas

Creating multidimensional array
        246118 by: Yonatan Ben-Nes
        246119 by: Jochem Maas
        246120 by: Robert Cummings

um ... arrays
        246121 by: Steven Macintyre
        246122 by: Stut
        246123 by: Edward Kay

random selection from each subfolder
        246124 by: Steven Macintyre

MS Outlook 2003 Options
        246125 by: Ray Hauge
        246128 by: Stut

Re: Are PHP5 features worth it?
        246126 by: tg-php.gryffyndevelopment.com
        246133 by: Bernhard Zwischenbrugger
        246134 by: Robert Cummings

parsing objects
        246127 by: Marcus
        246136 by: Roman Neuhauser

Re: ob_start("ob_gzhandler") and error handling functions
        246129 by: IG
        246130 by: Roman Neuhauser

Test
        246131 by: Ray Hauge
        246132 by: Ray Hauge

Re: Binary Config file: Protect script(s): Powered-by logo: How to?
        246135 by: Wonderskill

Count empty array
        246137 by: Kevin Murphy

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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 

--- End Message ---
--- Begin Message ---
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):
<?php
$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):
<?php
$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

--- End Message ---
--- Begin Message ---
you can do this with a bit of reference magic...

<?php

$ref  = null;
$keys = array("six","five","four","three","two","one");
$val  = "string value"; // the node value
$arr  = array(); // generated array

$ref =& $arr;

while ($key = array_pop($keys)) {
        $ref[$key] = array();
        $ref =& $ref[$key];
}

$ref = $val;
var_dump($arr);

?>

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):
> <?php
> $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):
> <?php
> $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
> 

--- End Message ---
--- Begin Message ---
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):
> <?php
> $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";');
> ?>

<?php

$new = array();
$ref = &$new;
foreach( array_reverse( $array ) as $key )
{
    $ref[$key] = array();
    $ref = &$ref[$key];
}
 
$ref['node_title'] = 'string value';

print_r( $new );

?>

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

--- End Message ---
--- Begin Message ---
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 .']=\'<a
href="?file='.$file.'&c='.$cat.'"><img src="'.$dirname.'/'.$file.'"
style="border:1px solid #bb3621"></a>\';' . "\n";
                         }
                 $curimage++;
               }
       }

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

now ... why does files not get shuffled?

Is that not the purpose of that function ?

Steven

--- End Message ---
--- Begin Message ---
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 .']=\'<a
href="?file='.$file.'&c='.$cat.'"><img src="'.$dirname.'/'.$file.'"
style="border:1px solid #bb3621"></a>\';' . "\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

--- End Message ---
--- Begin Message ---
$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 .']=\'<a
> href="?file='.$file.'&c='.$cat.'"><img src="'.$dirname.'/'.$file.'"
> style="border:1px solid #bb3621"></a>\';' . "\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
>
>
>

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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

 


--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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.

--- End Message ---
--- Begin Message ---
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:

<?xml version="1.0" encoding="utf-8"?>
<text>&Uuml; is not Ü</text>

(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.
> 

--- End Message ---
--- Begin Message ---
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:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <text>&Uuml; is not Ü</text>
> 
> (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.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
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 ---

--- End Message ---
--- Begin Message ---
# [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

--- End Message ---
--- Begin Message ---
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");|


--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2006-12-20 14:12:11 +0000:
> 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

--- End Message ---
--- Begin Message ---
Hey guys,

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

Thanks,
Ray

--- End Message ---
--- Begin Message ---
Hello everyone,

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

Thanks,
Ray

--- End Message ---
--- Begin Message ---
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:

<?php
                                        $script_root           = 
'download_center_lite/'; //or where ever
installed
                                        $dlcl                     = 
@file($script_root . 'inc/config.dat.php');
          $tplt                     = 'dlcl';
                                        unset($dlcl[0]);
          $dlcl = @array_values($dlcl);
          $str = '';
          $conf_var = '';
          for ($n = 0; $n < count(${$tplt}); $n++)
          {
              $c_var = '';
              for ($o = 7; $o >= 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:
> 
> 
> <?php exit(); ?>
> 11001100
> 01101100
> 00000100
> 10001100
> 00001100
> ...
> ... (Picture 1,667 lines of this)
> ...
> 11101100
> 00000100
> 00101100
> 11101100
> 00000100
> 
> 
> 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.

--- End Message ---
--- Begin 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



--- End Message ---

Reply via email to