php-general Digest 9 May 2013 05:08:09 -0000 Issue 8223
Topics (messages 321034 through 321047):
Re: FW:
321034 by: Daniel Brown
321038 by: Dan Joseph
321039 by: Ashley Sheridan
Re:
321035 by: Tedd Sperling
321036 by: Daniel Brown
321037 by: David OBrien
321040 by: Steven Staples
321041 by: Ashley Sheridan
321042 by: Daniel Brown
321043 by: Daniel Brown
Re: array_map() with multiple callback functions
321044 by: Jim Giner
321045 by: Andrew Ballard
321047 by: George Langley
Re: filesize question
321046 by: tamouse mailing lists
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
If you're going to send hack attempts, at least adjust your clock
so that it doesn't look like it took almost a month for your SPAM to
get here. We're not the Pony Express. (And, no, PHP doesn't stand
for Produced by Horses & Ponies.)
On Thu, Apr 11, 2013 at 11:43 AM, Paul Novitski
<p...@juniperwebcraft.com> wrote:
> http://www.shinwa-kensetsu.sakura.ne.jp/bth7rz.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
Yo,
(And, no, PHP doesn't stand
> for Produced by Horses & Ponies.)
>
>
This is completely devastating....
--
-Dan Joseph
http://www.danjoseph.me
http://www.dansrollingbbq.com
http://www.youtube.com/DansRollingBBQ
--- End Message ---
--- Begin Message ---
Dan Joseph <dmjos...@gmail.com> wrote:
>Yo,
>
> (And, no, PHP doesn't stand
>> for Produced by Horses & Ponies.)
>>
>>
>This is completely devastating....
Just noticed the original link has a nasty payload for android, I assume the
same applies for other OSs (probably best not to check!)
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---
--- Begin Message ---
On May 8, 2013, at 12:50 PM, Daniel Brown <danbr...@php.net> wrote:
> If you're going to send hack attempts, at least adjust your clock
> so that it doesn't look like it took almost a month for your SPAM to
> get here. We're not the Pony Express. (And, no, PHP doesn't stand
> for Produced by Horses & Ponies.)
>
> On Thu, Apr 11, 2013 at 11:43 AM, Paul Novitski
> <p...@juniperwebcraft.com> wrote:
>> http://www.shinwa-kensetsu.sakura.ne.jp/bth7rz.php
I'm not sure what's going on with Paul's account -- he doesn't "normally" do
stuff like that.
I even bought his book.
Cheers,
tedd
PS: PHP + > "Produced by Horses & Ponies." ? You got too much time on your
hands Daniel.
As for me, I just wasted 20+ hours on a clueless client. It would be nice if
people kept their word.
_____________________
tedd.sperl...@gmail.com
http://sperling.com
--- End Message ---
--- Begin Message ---
On Wed, May 8, 2013 at 1:14 PM, Tedd Sperling <tedd.sperl...@gmail.com> wrote:
>
> PS: PHP + > "Produced by Horses & Ponies." ? You got too much time on your
> hands Daniel.
Sometimes I wish that were the case. Honestly, I think it's
having a three-and-a-half-year-old daughter that's rubbing off on me.
She's presently obsessed with princesses (fictional, of course --- no
interest in Maria Antonia or even Kate Middleton yet). So you're just
lucky I didn't acronymize it as the Pretty House of Princesses or
something. And yes, I just made up the word acronymize. It may be
Wednesday, but it feels more like a Friday.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Wed, May 8, 2013 at 1:22 PM, Daniel Brown <danbr...@php.net> wrote:
> On Wed, May 8, 2013 at 1:14 PM, Tedd Sperling <tedd.sperl...@gmail.com>
> wrote:
> >
> > PS: PHP + > "Produced by Horses & Ponies." ? You got too much time on
> your hands Daniel.
>
> And yes, I just made up the word acronymize.
>
That would be reverse acronymization :)
--- End Message ---
--- Begin Message ---
> So you're just lucky I didn't acronymize it as the Pretty House of
> Princesses or something. And yes, I just made up the word
> acronymize. It may be Wednesday, but it feels more like a Friday.
>
Why does this feel like a new function/feature for PHP now?
Function acronymize($acronym)
{
// do stuff here now... :S
}
Steve
--- End Message ---
--- Begin Message ---
Steven Staples <sstap...@mnsi.net> wrote:
>> So you're just lucky I didn't acronymize it as the Pretty House of
>> Princesses or something. And yes, I just made up the word
>> acronymize. It may be Wednesday, but it feels more like a Friday.
>>
>
>Why does this feel like a new function/feature for PHP now?
>
>Function acronymize($acronym)
>{
> // do stuff here now... :S
>}
>
>Steve
Dont call it with the argument "php", you'll get stuck in a recursive loop!
And its not even Friday!
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---
--- Begin Message ---
On Wed, May 8, 2013 at 1:26 PM, David OBrien <dgobr...@gmail.com> wrote:
>
> That would be reverse acronymization :)
You're absolutely correct. Deacronymize?
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Wed, May 8, 2013 at 3:13 PM, Steven Staples <sstap...@mnsi.net> wrote:
>
> Why does this feel like a new function/feature for PHP now?
>
> Function acronymize($acronym)
> {
> // do stuff here now... :S
> }
<?php
function acronymize($text) {
preg_match_all('/[A-Z]/s',ucwords(strtolower($text)),$matches);
return implode('',$matches[0]);
}
?>
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
On 5/7/2013 5:29 PM, George Langley wrote:
Hi all. I want to apply strtolower() AND trim() to all items in an array. But I
don't see a way to call multiple callbacks with the array_map() function.
Are my two choices the following:
// 1) nesting two array_map() calls
$cleanData = array_map('trim',(array_map('strtolower',$rawData)));
// 2) call my own function with array_walk()
$cleanData = array_walk('myCleaner',$rawData);
function myCleaner($passedData){
$cleanData = array_map('strtolower',$passedData);
$cleanData = array_map('trim',$cleanData);
}
//(Of course, wouldn't bother with a function, just to call array_map twice...)
Just seeing if there's a better way than having to go through the array twice
to apply each callback separately. Thanks,
Not sure if you have an answer to this yet, so I'll present my simpler
approach.
foreach ($my_array as &$v)
{
$v = trim($v);
$v = strtolower($v);
}
--- End Message ---
--- Begin Message ---
On Tue, May 7, 2013 at 5:43 PM, Alex Nikitin <niks...@gmail.com> wrote:
> On Tue, May 7, 2013 at 4:29 PM, George Langley <george.lang...@shaw.ca> wrote:
>> Hi all. I want to apply strtolower() AND trim() to all items in an array.
>> But I don't see a way to call multiple callbacks with the array_map()
>> function.
>> Are my two choices the following:
>>
>> // 1) nesting two array_map() calls
>> $cleanData = array_map('trim',(array_map('strtolower',$rawData)));
>>
>>
>> // 2) call my own function with array_walk()
>> $cleanData = array_walk('myCleaner',$rawData);
>>
>> function myCleaner($passedData){
>> $cleanData = array_map('strtolower',$passedData);
>> $cleanData = array_map('trim',$cleanData);
>> }
>> //(Of course, wouldn't bother with a function, just to call array_map
>> twice...)
>>
>> Just seeing if there's a better way than having to go through the array
>> twice to apply each callback separately. Thanks,
> Something like:
>
> $cleanData = array_map(function($str){return strtolower(trim($str));},
> $passedData);
I'd go with this general approach, whether you use a named function or
an anonymous function for the callback. I don't know how large the
array is, but option #1 iterates the input array twice and option #2
iterates the array three times. If you eventually need to add
additional functions to clean the input, they would add even more
iterations. This approach only iterates once.
Andrew
--- End Message ---
--- Begin Message ---
On 2013-05-08, at 1:48 PM, Jim Giner wrote:
> On 5/7/2013 5:29 PM, George Langley wrote:
>> Hi all. I want to apply strtolower() AND trim() to all items in an array.
>> But I don't see a way to call multiple callbacks with the array_map()
>> function.
>> Are my two choices the following:
>>
>> // 1) nesting two array_map() calls
>> $cleanData = array_map('trim',(array_map('strtolower',$rawData)));
>>
>>
>> // 2) call my own function with array_walk()
>> $cleanData = array_walk('myCleaner',$rawData);
>>
>> function myCleaner($passedData){
>> $cleanData = array_map('strtolower',$passedData);
>> $cleanData = array_map('trim',$cleanData);
>> }
>> //(Of course, wouldn't bother with a function, just to call array_map
>> twice...)
>>
>> Just seeing if there's a better way than having to go through the array
>> twice to apply each callback separately. Thanks,
>>
> Not sure if you have an answer to this yet, so I'll present my simpler
> approach.
>
> foreach ($my_array as &$v)
> {
> $v = trim($v);
> $v = strtolower($v);
> }
>
> --
On 2013-05-07, at 3:43 PM, Alex Nikitin wrote:
> Something like:
>
> $cleanData = array_map(function($str){return strtolower(trim($str));},
> $passedData);
------
Thanks guys - will check both out to see what works best in my
situation.
George
--- End Message ---
--- Begin Message ---
On Tue, May 7, 2013 at 10:16 PM, Curtis Maurand <cur...@maurand.com> wrote:
> find -name *.js -exec removestring.php '{}' \;
>
> That's how I get the I put file name. I think that I need the if statement
> to look at the filesize and make sure that I can open them and they are at
> least the size of the string that I'm looking to cleanse.
That's how you pass the name into the php script; how does $inputfile
get set (via $argv somehow) once you're inside php?
This line:
>>> $inputline = fread($inputfile, filesize($argv[1]));
Somehow, you opened $inputfile (assuming via fopen) by passing it a
file name, presumably off the command line. Show me(us) where that
happens.
> Would that joomla.modules would use the ftp layer if it were turned on. Then
> I wouldn't have to be scanning files dor malicious iframes or if clamav
> coyld remove offending code without removing the entire file...
I don't know anything about joomla.
> tamouse mailing lists <tamouse.li...@gmail.com> wrote:
>>
>> On Tue, May 7, 2013 at 8:16 AM, Curtis Maurand <cur...@maurand.com> wrote:
>>>
>>> Hello,
>>> I'm feeding a filename to a php script on the command line (command line
>>> program). I run the following against it:
>>>
>>> $inputline = fread($inputfile, filesize($argv[1]));
>>>
>>> I'm getting an error complaining that the second parameter can't be '0'
>>
>>
>> The thing to look for, is how did you get $inputfile out of the
>> command line, and why you'd expect the file name to be in $argv[1] at
>> that point? Marco's suggestion isn't really going to work as
>> $inputfile will be a file handle, and filesize() needs the name of the
>> file. Maybe want to give us a wider look at what your code is doing?
>>
>> Generically, you can wrap this
>> up as:
>>
>> function binread_file($filename)
>> {
>> $handle = fopen($filename,'rb');
>> if (FALSE === $handle) die("Unable to open $filename");
>> $contents = fread($handle, filesize($filename));
>> if (FALSE === $contents) die("Unable to read $filename");
>> return $contents;
>> }
>
>
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---