php-general Digest 23 Jul 2007 11:00:56 -0000 Issue 4919
Topics (messages 259349 through 259364):
Re: Pirate PHP books online?
259349 by: Ryan A
259358 by: Sancar Saran
259359 by: Crayon Shin Chan
259362 by: David Powers
259363 by: Sancar Saran
259364 by: David Powers
Re: RecursiveArrayIterator
259350 by: Kevin Waterson
259351 by: Kevin Waterson
259353 by: Nathan Nobbe
259354 by: Jim Lucas
259357 by: Kevin Waterson
Re: checking if extension loaded
259352 by: Vanessa Vega
strange stripos behavior
259355 by: Bruce Cowin
can't open a file
259356 by: Ken Tozier
259361 by: Crayon Shin Chan
Re: #2003 - The server is not responding
259360 by: Ryan Lao
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:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hey,
<clip David>
Piracy, unauthorized copying, call it what you will, involves a chain.
Perhaps if the poor saps who make the unauthorized copies realized just
how they're being exploited, things might change.
</clip David>
Sorry, but disagree with you here, the "poor saps" know the site owners are
making money but just dont give a crap... the actual reason they choose to
upload and share can probably start another thread thats longer than this one...
but IMHO they know how it works and just want to share. They know they cant
make a
cent off it coz if the site owners started to pay them... theres a money trail
that
can be picked up/traced and they get into trouble...
This way they upload if they want to... and downloads are always there..
<clip Crayon>
Not exactly, Adam's payback is that he hopes others do the same, so where he
uploaded one item, he is able to download hundreds and thousands of
items that others have uploaded.
</clip Crayon>
Disagree again, if Adam uploads or not, there is a whole bunch of stuff out
there that he cant hope to download in a lifetime. Even if you are "member" of
a torrent site, you dont have to upload to download files.... once you finish
your download you can continue to share (seed) the file to others (if you need
to mantain your "up/down ratio"). Not everyone who downloads uploads new files..
Like I said above, the actual motivation for Adam to upload a new file can
feed a whole new looongg thread...so I wont even go there.
Cheers!
R
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo!
FareChase.
--- End Message ---
--- Begin Message ---
This is sucks,
Those publishers ripping the authors then they blame the pirates...
Real steal was %95 of book prices....
Regards
Sancar
--- End Message ---
--- Begin Message ---
On Monday 23 July 2007 08:45, Ryan A wrote:
> Disagree again, if Adam uploads or not, there is a whole bunch of stuff
> out there that he cant hope to download in a lifetime.
It was never mentioned *when* Adam uploaded his file, it could've been
when the site first started out and uploads then were lacking.
> Even if you are
> "member" of a torrent site, you dont have to upload to download
> files.... once you finish your download you can continue to share
> (seed) the file to others (if you need to mantain your "up/down
> ratio"). Not everyone who downloads uploads new files..
Leechers would always outnumber the contributors, but apparently Adam is a
responsible member of the community who gives as well as take.
--
Crayon
--- End Message ---
--- Begin Message ---
Sancar Saran wrote:
Those publishers ripping the authors then they blame the pirates...
Real steal was %95 of book prices....
No, the author gets 10% of what the publisher gets. If you look at
prices on Amazon or other online bookstores, you'll see that 35-40%
discount is common. So, a $40 book often sells for $26 or less. Delivery
within the same country is frequently free, so that's a cost that gets
deducted. Amazon also pays a commission to websites with affiliate
links. So the publisher ends up with less than $20.
Publishing a book involves a lot of people: not just the author, but at
least one technical reviewer, editor, copy editor, indexer, compositor
(who lays out the pages), designer, and printer. Printed books also need
to be transported and stored. The costs quickly mount up.
EBooks are cheaper to produce because there's no cost for printing or
storage, but a professionally produced eBook still takes a huge amount
of human effort. Unfortunately, an eBook is very easy for a pirate to
rip off. The danger with piracy is that authors will be discouraged from
writing, and in the end everyone will be worse off.
David Powers
--- End Message ---
--- Begin Message ---
On Monday 23 July 2007 12:20:50 David Powers wrote:
> Sancar Saran wrote:
> > Those publishers ripping the authors then they blame the pirates...
> >
> > Real steal was %95 of book prices....
>
> No, the author gets 10% of what the publisher gets. If you look at
> prices on Amazon or other online bookstores, you'll see that 35-40%
> discount is common. So, a $40 book often sells for $26 or less. Delivery
> within the same country is frequently free, so that's a cost that gets
> deducted. Amazon also pays a commission to websites with affiliate
> links. So the publisher ends up with less than $20.
>
> Publishing a book involves a lot of people: not just the author, but at
> least one technical reviewer, editor, copy editor, indexer, compositor
> (who lays out the pages), designer, and printer. Printed books also need
> to be transported and stored. The costs quickly mount up.
>
> EBooks are cheaper to produce because there's no cost for printing or
> storage, but a professionally produced eBook still takes a huge amount
> of human effort. Unfortunately, an eBook is very easy for a pirate to
> rip off. The danger with piracy is that authors will be discouraged from
> writing, and in the end everyone will be worse off.
>
> David Powers
It was still ripping, They got 18 USD you got 2 USD. This is sucks. I'm not
sure author of Harry Potter acceps same condition.
You made everyone rich except yourself...
Regards
Sancar
--- End Message ---
--- Begin Message ---
Sancar Saran wrote:
It was still ripping, They got 18 USD you got 2 USD.
Out of that $18, the publisher has to pay the editor, copy editor,
technical reviewer, compositor, printer, etc, etc. Unless the book sells
several thousand copies, the publisher normally makes a loss.
I'm not
sure author of Harry Potter acceps same condition.
The Harry Potter books have sold an estimated 325 million copies. Even
if the author gets only 10 cents a book, that adds up to $32.5 million.
I'm sure she gets a lot more than 10 cents a book, but it's the number
of books sold that makes the real difference, not the amount per book.
Harry Potter also generates a lot of money through Hollywood movie
rights. It's hard to imagine the same with a book about PHP. ;-)
You made everyone rich except yourself...
I don't mind others making money out of my books, as long as they have
contributed to them in a positive way. Publishing books involves a lot
of people. They all need to be paid. The publisher takes a gamble,
paying everybody up front before a single copy is sold. Since most books
make a loss, it's reasonable for the publisher to take a share of the
profit of successful books. As far as an author is concerned, the deal
lies in royalties. The more books you sell, the more you get. I also get
a higher share of the profit if the book sells more than a specified amount.
David Powers
--- End Message ---
--- Begin Message ---
This one time, at band camp, "Nathan Nobbe" <[EMAIL PROTECTED]> wrote:
Thanks for the response.
I was hoping to avoid this sort of recursion within userspace and keep
it at a lower level. Should not the recursive iterator recurse so we
dont need to be using user defined functions?
> printArrayKeysRecursively($innerRecursiveArrayIterator); // handle printing
Kind regards
Kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
--- End Message ---
--- Begin Message ---
This is what I have so far..
<?php
$array = array(
array('name'=>'butch', 'sex'=>'m', 'breed'=>'boxer'),
array('name'=>'fido', 'sex'=>'m', 'breed'=>'doberman'),
array('name'=>'girly','sex'=>'f', 'breed'=>'poodle')
);
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
while($iterator->valid())
{
if(!$iterator->hasChildren())
{
echo $iterator->key().' -- '.$iterator->current().'<br/>';
}
$iterator->next();
}
?>
Kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
--- End Message ---
--- Begin Message ---
there is no base case in the printArrayKeysRecursively method;
therefore it is not handling recursion; its just using the
RecursiveArrayItereators public methods. i think that is totally appropriate.
but i believe i understand what youre getting at; namely the
RecursiveArrayIterator implments Iterator, sooo, we should be able
to use the foreach construct in our client code to cleanly iterate over the
object. here is a new revision, which you may like more
than the first one:
<?php
$array = array(
array('name'=>'butch', 'sex'=>'m', 'breed'=>'boxer'),
array('name'=>'fido', 'sex'=>'m', 'breed'=>'doberman'),
array('name'=>'girly','sex'=>'f', 'breed'=>'poodle')
);
$iterator = new RecursiveArrayIterator($array);
foreach($iterator as $outerValue) {
foreach($outerValue as $innerKey => $innerValue) {
echo $innerKey . ' => ' . $innerValue . PHP_EOL;
}
}
?>
notice that there are 2 foreach invocations; those correspond directly to
the levels of nesting in $array. so if you had another level of
nesting in $array, there would have to be another level of nesting in the
foreach invocations (if you want to do something w/ those values). that
brings us to RecursiveIteratorIterator
which quoting Harry Fuecks in his article on
SPL<http://www.sitepoint.com/article/php5-standard-library>
*RecursiveIteratorIterator: this helps you do cool stuff like "flatten" a
hierarchical data structure so that you can loop through it with a single
foreach statement, while still preserving knowledge of the hierarchy. This
class could be very useful for rendering tree menus, for example.
*as i understand it RecursiveIteratorIterator essentially allows you to
define a particular action depending on which level of children is currently
being operated on. so i think the decision to use that over
RecursiveArrayIterator comes down to the number of levels of nesting that
will be in your data structure. if it will always be 2 levels (or a static
number of levels that is relatively small), stick w/ RecursiveArrayIterator,
otherwise if the number of nested levels is going to vary (or be more than a
few), i think, thats when you need to consider RecursiveIteratorIterator.
-nathan
note: im still a newb on spl myself :)
On 7/22/07, Kevin Waterson <[EMAIL PROTECTED]> wrote:
This one time, at band camp, "Nathan Nobbe" <[EMAIL PROTECTED]>
wrote:
Thanks for the response.
I was hoping to avoid this sort of recursion within userspace and keep
it at a lower level. Should not the recursive iterator recurse so we
dont need to be using user defined functions?
> printArrayKeysRecursively($innerRecursiveArrayIterator); // handle
printing
Kind regards
Kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Kevin Waterson wrote:
This is what I have so far..
<?php
$array = array(
array('name'=>'butch', 'sex'=>'m', 'breed'=>'boxer'),
array('name'=>'fido', 'sex'=>'m', 'breed'=>'doberman'),
array('name'=>'girly','sex'=>'f', 'breed'=>'poodle')
);
$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
while($iterator->valid())
{
if(!$iterator->hasChildren())
{
echo $iterator->key().' -- '.$iterator->current().'<br/>';
}
$iterator->next();
}
?>
Kevin
I don't get it, why not do this?
<?php
$array = array(
array('name'=>'butch', 'sex'=>'m', 'breed'=>'boxer'),
array('name'=>'fido', 'sex'=>'m', 'breed'=>'doberman'),
array('name'=>'girly','sex'=>'f', 'breed'=>'poodle')
);
foreach ( $array AS $row ) {
foreach ( $row AS $k => $v ) {
if ( ! is_array($v) ) {
echo "{$k} -- {$v}<br/>\n";
}
}
}
?>
This seems like a few less lines of code
Maybe I am missing the point... ???
Jim Lucas
--- End Message ---
--- Begin Message ---
This one time, at band camp, Jim Lucas <[EMAIL PROTECTED]> wrote:
> I don't get it, why not do this?
> foreach ( $array AS $row ) {
> foreach ( $row AS $k => $v ) {
> if ( ! is_array($v) ) {
> echo "{$k} -- {$v}<br/>\n";
> }
> }
> }
>
> Maybe I am missing the point... ???
Indeed, whilst your method is simplistic it leaves many copies of the array
dangling in memory. Every time you call foreach it creates a copy of the
array internally. SPL iterators do things differently and know only one
element at a time. More can be seen at
http://phpro.org/tutorials/Introduction-to-SPL.html
so the final solution was using a foreach, however, using a foreach on an
SPL iterator object implicitly calls the inner iterator giving us all the
SPL goodness in memory savings.
Kind regards
Kevin
--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."
--- End Message ---
--- Begin Message ---
The GD library was installed by the administrator, so now....the function
already works.....:-)
""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Wed, July 18, 2007 4:37 am, Vanessa Vega wrote:
>> I have a function that creates a thumb file(thumbnail) and and an
>> image
>> file(preview pic) in php. It starts with:
>> function ($picFile, $thumbFile, $imageFile) {
>> if (extension_loaded('gd') {
>> ......codes to create thumb and preview pic...
>>
>> else
>> ......creating images failed
>>
>> }
>> everytime i test it, the function fails to create the images...
>>
>> This function works in joomla..............
>>
>> sorry....im just new to php programming.....:-)
>
> Is joomla running on the same server as your php script?
>
> I will assume not.
>
> Does <?php phpinfo();?> list "GD" as one of the loaded extensions?
>
> I will assume not.
>
> The solution, then, is to install GD so that you have the GD functions
> available to you.
>
> --
> 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/browse/from/lynch
> Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
I'm using PHP 5.1 on IIS. I have an app that uses MimeDecode to load
mime files and I've built an object to parse them into their various
parts; i.e., $msg->Body(), $msg->Sender(), etc. I'm using stripos() to
look for a string (that I know is in my test files). It works if I
search in $msg->Body(), but doesn't work if I build a variable and
search it. i.e.,
this works:
if (!stripos($msg->Body(), 'xxxx') === false)
{
echo "\n found in Body()\n";
}
but this doesn't (I've tried it with and without htmlentities()):
$searchtext = htmlentities($msg->Sender()) . htmlentities($msg->To()) .
htmlentities($msg->Cc()) . htmlentities($msg->Subject()) .
htmlentities($msg->Body());
if (!stripos($searchtext, 'xxxx') === false)
{
echo "\nstring found!\n";
}
Does anyone have any ideas? Thanks.
Regards,
Bruce
--- End Message ---
--- Begin Message ---
Hi
I'm trying to create/open a file for write in a subfolder of the
folder that contains my PHP script but am having no luck.
Here's the relevant code
$oldPath =
'/test/old_page_'.$oldRecord['page_number'].'.txt';
$oldHand = fopen($oldPath, "w+");
if ($oldHand === true)
fwrite($oldHand, $oldData);
else
die('Failed to open file "'.$oldPath.'" for writing!');
fclose($oldHand);
The permissions for the "test" folder is set to me in a WebServer
subfolder on Mac OS X. Do I need to set permissons to something else
to get this to work? If so, what permissions should I use?
Thanks for any help
Ken
--- End Message ---
--- Begin Message ---
On Monday 23 July 2007 12:23, Ken Tozier wrote:
> The permissions for the "test" folder is set to me in a WebServer
> subfolder on Mac OS X.
What exactly does "permission ... set to me" mean?
> Do I need to set permissons to something else
> to get this to work? If so, what permissions should I use?
If you wanted to be able to create a file in the directory:
/a/b/c/d
then you would need 'execute' permission on each of the directory:
/a
/a/b
/a/b/c
/a/b/c/d
in addition you need 'write' permission for the directory that the file is
created in, ie:
/a/b/c/d
--
Crayon
--- End Message ---
--- Begin Message ---
okay. I'll check on that one. Thanks
""Daniel Brown"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 7/16/07, Ryan Lao <[EMAIL PROTECTED]> wrote:
>> I uninstalled my old versions of apache, mysql and php then installed
>> wamp
>> on my computer. everything seems to be working when i access localhost,
>> except when i go to phpmyadmin. I get this error on screen "MySQL said:
>> #2003 - The server is not responding"... so i updated the config.php file
>> but still i get the same error. does this have to do with the old
>> password
>> or username that i used before with my old mysql? or is it something else
>> entirely? some help would really be appreciated....
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> That's actually a MySQL rather than PHP question, but the error
> message gives you the answer in context:
>
> "The server is not responding"
>
> 1.) Check to make sure it's installed properly.
> 2.) Check to ensure that MySQL starts and runs properly without
> quitting.
> 3.) Check the ports on which MySQL's daemon is set to listen.
> 4.) Attempt to connect via the shell to MySQL.
> 5.) Check your configure.inc.php (I think that's what phpMyAdmin uses)
> 5a.) Make sure the IP/hostname is correct
> 5b.) If not localhost, make sure the port number is correct
> 6.) If connecting to anything other than `localhost` check your
> firewall settings
>
> The username/password combination will have nothing to do with
> this particular error, but may become an issue once you've connected
> to the server.
>
> --
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
--- End Message ---