Re: [PHP] stream_socket_accept() on an SSL socket

2008-12-02 Thread German Geek
When you "talk" to an SSL server directly with sockets, I believe you need
to implement the SSL protocol yourself, which would probably be overkill.
There must be a PHP library which does or a native function. You should
probably look at this page:
http://nz.php.net/manual/en/wrappers.http.php

and use fopen instead.

On Wed, Dec 3, 2008 at 12:57 PM, Ashley Sheridan
<[EMAIL PROTECTED]>wrote:

> On Tue, 2008-12-02 at 23:48 +, Darren wrote:
> > I'm trying to connect to an SSL server, but I keep on getting these
> errors:
> > -
> > PHP Warning:  stream_socket_accept(): SSL operation failed with code 1.
> > OpenSSL Error messages:
> > error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol in
> > C:\scripts\bouncer.php on line 273
> > PHP Warning:  stream_socket_accept(): Failed to enable crypto in
> > C:\scripts\bouncer.php on line 273
> > PHP Warning:  stream_socket_accept(): accept failed: The operation
> > completed successfully.
> >   in C:\scripts\bouncer.php on line 273
> > -
> >
> > Line 273: while ($client = stream_socket_accept($srv_socket)) {
> >
> > Over the past few days of searching I've found a lot of people asking a
> > similar thing but without any answers. I've tried the latest PHP
> > snapshot too.
> >
> > Can anyone here give any insight to these errors??
> >
> > Thanks for any help
> > Darren
> >
> I believe this shares something in common with another thread [Slow File
> Download]. Sockets on IIS using SSL has some problems. It's possible
> that the one you're suffering here is where IIS closes the connection
> prematurely. I have no idea how to solve this, but there are a number of
> answers to something similar on the PHP manual pages as far as I know.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] Accessing the 'media' attribute in php

2008-12-02 Thread German Geek
PHP is a server side language...

On Wed, Dec 3, 2008 at 2:16 PM, Clancy <[EMAIL PROTECTED]> wrote:

> Is it possible to access the 'media' attribute from php, so (for
> example) you can tailor a page for printing?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] Accessing the 'media' attribute in php

2008-12-02 Thread German Geek
You can do things on the client side with Javascript ;) Sorry, what was the
result you are after?

On Wed, Dec 3, 2008 at 3:22 PM, Clancy <[EMAIL PROTECTED]> wrote:

> Oh?
>
> Unfortunately I have had great difficulty trying to find out how
> things really work, as all the books I have seen are recipe books,
> which tell you how to achieve particular results, but not what is
> going on behind the scenes.  I had assumed that when you hit the
> 'print' button the browser sent a new request to the server, with a
> different set of parameters, but I gather from your reply that the
> browser issues the new (printer) page without reference to the server.
> Is this what actually happens?
>
> If so I fear I will have to work out how to achieve the results I want
> with CSS styles.  It would have been far simpler if I could have done
> it in php.
>
> Thank you for your help.
>
> On Wed, 3 Dec 2008 14:34:20 +1300, [EMAIL PROTECTED] ("German Geek")
> wrote:
>
> >PHP is a server side language...
> >
> >On Wed, Dec 3, 2008 at 2:16 PM, Clancy <[EMAIL PROTECTED]> wrote:
> >
> >> Is it possible to access the 'media' attribute from php, so (for
> >> example) you can tailor a page for printing?
> >>
> >>
> >> --
> >> 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
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] IE8 and HTML5

2008-12-04 Thread German Geek
Recently, I installed IE8 beta 2 and whenever I start it, DEP comes in and
says, this application is not secure... I haven't got it to run as yet. The
reason I installed it was because a client reported problems with a web app
written by me with IE8. Now I can't run IE altogether lol. Yeah, I knew
before I installed it, that whenever M$ claim that it's beta, it more like a
alpha release with version no 0.0001a and when they sell it it's beta... lol

On Thu, Dec 4, 2008 at 9:45 PM, Richard Heyes <[EMAIL PROTECTED]> wrote:

> Hi,
>
> From a recent IEBlog post:
>
>
> http://blogs.msdn.com/ie/archive/2008/12/03/compatibility-view-improvements-to-come-in-ie8.aspx
>
> > ...and our start on HTML5 support.
>
> Does this mean canvas support? Is it as a direct result of Chrome
> being released and MS realising (finally) they are going to have to
> remain competitive? Wouldn't that be nice?
>
> --
> Richard Heyes
>
> HTML5 Graphing for FF, Chrome, Opera and Safari:
> http://www.rgraph.org (Updated November 29th)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] Will not report errors what can I do

2008-12-04 Thread German Geek
On Fri, Dec 5, 2008 at 4:26 PM, Robert Cummings <[EMAIL PROTECTED]>wrote:

> On Thu, 2008-12-04 at 15:07 -0800, Jim Lucas wrote:
> > Terion Miller wrote:
> > > Hey everyone I am still fighting the same problem that my script isn't
> > > working and its not reporting errors, when you click to "view" the work
> > > order it doesn't do anything, I have all kinds of error reporting
> turned on
> > > but nothing, do I have them syntax wrong?
> > >
> > >  > > include("inc/dbconn_open.php");
> > > error_reporting(E_ALL);
> > >  ini_set('display_errors', '1');
> >
> > This is boolean, it should be ini_set('display_errors', 1);
>
> Isn't 1 an integer and true a boolean? ;)
>
> Anyways, what I noticed is that error reporting is enabled after an
> include. Maybe the system is failing during the include.

1 and true can usually be used interchangeably in most programming languages
because true is stored as something bigger than (or different to) 0 and
false as 0. But it's clearer for the programmer to use true and false
because it's clearer as what its semantics are. Important for computer
science: "The difference between syntax and semantics"...

>
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] Parsing Strings

2008-12-07 Thread German Geek
Why not preg_split ( http://nz.php.net/manual/en/function.preg-split.php ):

$str = 'SCOTTSDALE, AZ 85254';
$ar = preg_split('/,? ?/', $str); //optional comma, followed by optional
space
// $ar = array('SCOTTSDALE', 'AZ', '85254');

On Sat, Dec 6, 2008 at 1:18 PM, Jason Todd Slack-Moehrle <
[EMAIL PROTECTED]> wrote:

>
> How might I also parse and address like: SCOTTSDALE, AZ 85254
>
> It has a comma and a space
>
> -Jason
>
>
> On Dec 5, 2008, at 4:02 PM, Jason Todd Slack-Moehrle wrote:
>
>  OK, making good learning progress today.
>>
>> I have a string that is: Jason Slack
>>
>> and I want it broken at the space so i get Jason and then Slack
>>
>> I am looking at parse_str, but I dont get how to do it with a space. The
>> example is using []=.
>>
>> Then I want to assign like:
>>
>> $fname = "Jason";
>> $lname = "Slack";
>>
>> Any ideas?
>>
>> -Jason
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-07 Thread German Geek
EXIST?  Yeah I certainly have seen it before in the result of a mysqldump,
but from the top of my head, I probably wouldn't have known in exactly what
context it is used. I've used MySQL for 5 years now and i think if you ask
such a question, you don't know what you should be asking because the
context of EXIST is hardly ever needed, and if, if you know where to look
for it, that's more important than being able to reproduce it in from the
top of your head. It's like asking: "Do you know the syntax for ..." where
... is a rarely used function in PHP or any other language. It's like
requiring your employees to know every function of a language...

On Mon, Dec 8, 2008 at 4:03 AM, tedd <[EMAIL PROTECTED]> wrote:

> Hi gang:
>
> I just interviewed for a job teaching at the local college (imagine me
> taking minds of mush and molding them to the world according to tedd --
> frightening huh?)
>
> In any event, the interviewer asked me how long I've been using MySQL and I
> replied several years. After which she asked a single question, which was
> "What does EXIST mean?"
>
> Now without running to the manuals, please be honest and tell me how many
> of you know off the top of your head what EXIST means? I would be curious to
> know.
>
> I answered the question correctly, (I'm one of those weird types who read
> manuals for fun) but I have never used EXIST in a query. Have any of you?
>
> And while we're on the subject of MySQL -- while we all know how to write
> it, how do you say it?
>
> I've read that the common way is to say "My Squell", or something like
> that. But I always sounded out each letter, such as "My S-Q-L". The
> interviewer pronounced it the same as I, but I have heard others say it
> differently.
>
> What say you?
>
> Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-07 Thread German Geek
On Mon, Dec 8, 2008 at 2:59 PM, Chris <[EMAIL PROTECTED]> wrote:

> German Geek wrote:
>
>> EXIST?  Yeah I certainly have seen it before in the result of a mysqldump,
>> but from the top of my head, I probably wouldn't have known in exactly
>> what
>> context it is used. I've used MySQL for 5 years now and i think if you ask
>> such a question, you don't know what you should be asking because the
>> context of EXIST is hardly ever needed, and if, if you know where to look
>> for it, that's more important than being able to reproduce it in from the
>> top of your head. It's like asking: "Do you know the syntax for ..." where
>> ... is a rarely used function in PHP or any other language. It's like
>> requiring your employees to know every function of a language...
>>
>
> You're making an assumption about the situation. What if it was for a dba
> job or teaching advanced sql?
>
> And 'exists' is not for mysqldump.


DROP TABLE IF EXISTS `mytable`;

I said, I've seen EXIST in a result of a mysqldump before, which is not
wrong is it? Unless I'm hallucinating... Or is EXISTS something completely
different?
And even a DBA or teacher doesn't need to know every part of syntax in
MySQL. It's more important that they know the concepts...

Anyway, I think this is all off-topic in a PHP mailing list...


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


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-07 Thread German Geek
On Mon, Dec 8, 2008 at 3:24 PM, Chris <[EMAIL PROTECTED]> wrote:

>
> And 'exists' is not for mysqldump.
>>
>>
>> DROP TABLE IF EXISTS `mytable`;
>>
>
> "if exists" can be used in lots of places other than "drop table", like
> triggers, functions and i'm sure other things.
>
>  I said, I've seen EXIST in a result of a mysqldump before, which is not
>> wrong is it? Unless I'm hallucinating... Or is EXISTS something completely
>> different?
>>
>
> Yes it is completely different.

Sorry, I couldnt find EXIST there, only EXISTS.


>
>
>
> http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-07 Thread German Geek
On Mon, Dec 8, 2008 at 5:06 PM, Chris <[EMAIL PROTECTED]> wrote:

> German Geek wrote:
>
>>
>>
>> On Mon, Dec 8, 2008 at 3:24 PM, Chris <[EMAIL PROTECTED] > [EMAIL PROTECTED]>> wrote:
>>
>>
>>   And 'exists' is not for mysqldump.
>>
>>
>>DROP TABLE IF EXISTS `mytable`;
>>
>>
>>"if exists" can be used in lots of places other than "drop table",
>>like triggers, functions and i'm sure other things.
>>
>>
>>I said, I've seen EXIST in a result of a mysqldump before, which
>>is not wrong is it? Unless I'm hallucinating... Or is EXISTS
>>something completely different?
>>
>>
>>Yes it is completely different.
>>
>> Sorry, I couldnt find EXIST there, only EXISTS.
>>
>
> If you're going to be that pedantic, "exist" isn't in mysqldump either :P
>
I know it's pedantic, but unfortunately computers are strictly pedantic and
I wasn't sure why you said
"if exists" can be used in lots of places other than "drop table",
like triggers, functions and i'm sure other things."
I was just stating that I saw it in a dump and I never really used it, so
assume(d), it's not very important because you can do the same thing with IN
etc and other conditions, can't u?

Anyway, this discussion is getting rediculous. Let's move on. Didn't mean to
offend anyone here. Don't worry about answering the last question if you
also think it's irrelevant...

All good. :)

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


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-07 Thread German Geek
On Mon, Dec 8, 2008 at 5:50 PM, Chris <[EMAIL PROTECTED]> wrote:

>
> Sorry, I couldnt find EXIST there, only EXISTS.
>>
>>
>>If you're going to be that pedantic, "exist" isn't in mysqldump
>>either :P
>>
>> I know it's pedantic, but unfortunately computers are strictly pedantic
>> and I wasn't sure why you said "if exists" can be used in lots of places
>> other than "drop table",
>> like triggers, functions and i'm sure other things."
>> I was just stating that I saw it in a dump and I never really used it, so
>> assume(d), it's not very important because you can do the same thing with IN
>> etc and other conditions, can't u?
>>
>
> They are completely different things you're mixing up here.
>
> "IF EXISTS" with "DROP TABLE" means "if the table does not exist, do not
> give an error".

I do understand that it's a bit different here.

>
>
> Same for "drop view", "drop trigger". If the view/table/trigger/function
> does not exist, do not give an error.
>
> "EXISTS" in a select query is a subquery - same as using "IN".
>
> Completely different.
>

Right

So, how are these different:

SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2)
to
SELECT * FROM t1 WHERE id IN (SELECT id FROM t2)

??
According to my understanding of the documentation, these would have the
same result. Can't think of any sub query that could not have an equivalent
statement with IN (NOT IN).

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


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-07 Thread German Geek
On Mon, Dec 8, 2008 at 7:06 PM, Chris <[EMAIL PROTECTED]> wrote:

>
>  Right
>>
>> So, how are these different:
>>
>> SELECT * FROM t1 WHERE id EXISTS (SELECT id FROM t2)
>>
>
> If there are *any* results for the subselect, the exists returns true.
>
> It's the equivalent of:
>
> select * from t1 where id is true;
>
> ie
>
> select * from t1;
>
> If there are no results for the subselect, the exists returns false, ie:
>
> select * from t1 where false;
>
> which will return nothing.
>
>  to
>> SELECT * FROM t1 WHERE id IN (SELECT id FROM t2)
>>
>
> this returns specific id's that match.
>
>  According to my understanding of the documentation, these would have the
>> same result.
>>
>
> No, they aren't.
>
> create table t1(id int, name varchar(5));
>
> insert into t1(id, name) values (1, 'one');
> insert into t1(id, name) values (2, 'two');
> insert into t1(id, name) values (3, 'three');
> insert into t1(id, name) values (4, 'four');
> insert into t1(id, name) values (5, 'five');
>
> create table t2(id int, other_name varchar(5));
>
> insert into t2(id, other_name) values (1, 'one');
> insert into t2(id, other_name) values (2, 'two');
>
> this returns everything from t1:
> SELECT * FROM t1 WHERE EXISTS (SELECT id FROM t2);
>
> this returns 2 rows that match:
> SELECT * FROM t1 WHERE id IN (SELECT id FROM t2);


Oh OK. Thanks for clearing that up.

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


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] Include directive..

2008-12-08 Thread German Geek
On Tue, Dec 9, 2008 at 12:47 AM, dele454 <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I am modifying the apache config file on my domain to include the path to
> the Zend Framework on a specified location outside the public folder.
>
> So in my http.conf file i simply include the path to where the includes
> file
> is to customise the virtual host:
>
> [CODE]
>
> # To customize this VirtualHost use an include file at the following
> location
> Include
> "/usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf"
> [/CODE]
>
> And then me.conf looks like this:
> [CODE]
> Include "/home/domain/apps"
> Include "/home/domain/apps/models"
> Include "/home/domain/apps/lib"
> [/CODE]
>
> But then i get this error:
>
> [CODE]
> Failed to generate a syntactically correct Apache configuration.
> Bad configuration file located at
> /usr/local/apache/conf/httpd.conf.1228614930
> Error:
> Configuration problem detected on line 277 of file
> /usr/local/apache/conf/httpd.conf.1228614930:: Syntax error on line
> 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
> Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
> /home/maineven/apps/Bootstrap.php:1:  was not closed.[/CODE]
>

You get this error because you are trying to include a php file in the
apache configuration. Apache config files have tags, such as  and
 ... 

If you want to include php scripts in your php file, you should do that
there, e.g. in incfiles.php:
http://nz2.php.net/autoload ).


Re: [PHP] Accounting component in PHP

2008-12-08 Thread German Geek
You can do raw SQL queries with ORM as well, at least in symfony ;). An ORM
makes other, rather trivial queries a whole lot easier though and a
framework like symfony makes development of generic requirements a lot
faster and cleaner.

On Tue, Dec 9, 2008 at 4:07 AM, altern <[EMAIL PROTECTED]> wrote:

>
> Hello, guys. Could please someone recommend me component wiritten in PHP
> which makes financial calculations with predefined logic? I have DB with
> sales information in several tables and I need to implement business logic
> that includes many rules of charging, different interest rates and so on. I
> need some example at least. It seems to me that I'm trying to reinvent a
> wheel. Design patterns have not helped me yet. I even do not know in where
> should I look to find example implementation.
>
> To describe better what I mean, I will show one of the terrible SQL that is
> used to calculate some numbers in loop during further traversing:
>
> SELECT r.CODE,
>r.ORDER_NUM,
>r.REG_DATE,
>r.ORDER_EMAIL,
>r.STATUS,
>r.PRICE,
>r.BILLING_PERCENT,
>r.REGISTRATOR_PERCENT,
>r.REFUND_DATE,
>IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.CANCEL_FEE * (1 -
> r.BILLING_PERCENT/100
> - r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100),
>c.CANCEL_FEE) as CANCEL_FEE,
>IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.REFUND_FEE * (1 -
> r.BILLING_PERCENT/100
> - r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100),
>c.REFUND_FEE) as REFUND_FEE,
>IF(r.MIDDLE_CONTRACT_PERCENT > 0, COALESCE(r.REFUND_FEE,
> c.CHARGEBACK_FEE)
> * (1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
> r.MIDDLE_CONTRACT_PERCENT/100),
>COALESCE(r.REFUND_FEE, c.CHARGEBACK_FEE)) as CHARGEBACK_FEE,
>c.PERSON_LOGIN as CLIENT,
>r.ORDER_NAME,
>r.ORDER_NUM,
>r.ORDER_EMAIL,
>r.PRICE*(1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
> IF(r.MIDDLE_CONTRACT_PERCENT IS NOT NULL, r.MIDDLE_CONTRACT_PERCENT/100,
> 0))
> as INCOME,
>r.PRICE*(1 - r.REGISTRATOR_PERCENT/100) as REGISTRATOR_SUM,
>r.PRICE*r.BILLING_PERCENT/100 as BILLING_INCOME,
>r.REFUND_TYPE,
>r.MIDDLE_CONTRACT_PERCENT FROM SOFT_REG r,
>SOFT_CONTRACT c,
>SOFT_PRODUCT p
> WHERE
>p.CODE=r.PRODUCT_CODE
>AND p.CONTRACT_CODE=c.CODE
>AND c.CODE=5
>AND r.REG_DATE >= '2008-08-01 00:00:00'
>AND r.REG_DATE <= '2008-08-02 23:59:59'
>
> After querying this sql many other things happen to get specific results on
> my page. Results of this (and other similar queries) are used in several
> places on the same page. I'm totally confused with all this stuff and
> barely
> can make the code do what I want. One of the problems is that there are
> even
> no unit-tests to keep code tested on regressions. I make conclusion that I
> need separate component with object-oriented API to have possibility of
> running unit tests and to have logically structured code, which I could
> work
> with without confusion.
>
> ORM usage is not a solution. It would just complexify what I already have
> because sometimes too many tables are joining together. But again, I don't
> know what idea I can start with to manage all this.
>
> Thanks in advance. Any suggestions will be appreciated.
> --
> View this message in context:
> http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20897026.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-08 Thread German Geek
On Tue, Dec 9, 2008 at 2:46 PM, Micah Gersten <[EMAIL PROTECTED]> wrote:

> Robert Cummings wrote:
> > On Tue, 2008-12-09 at 00:16 +, Nathan Rixham wrote:
> >
> >> Ashley Sheridan wrote:
> >>
> >>> On Mon, 2008-12-08 at 23:23 +, [EMAIL PROTECTED] wrote:
> >>>
>  Presumable, the EXISTS sub-query can be optimized sometimes to just
> stop processing the sub-query and kick things back out to the outer query.
> 
> 
> 
>  IN has to process them all and find them all.
> 
> 
> 
> 
> >>> Don't forget the special case use as well:
> >>>
> >>> IF NOT EXISTS `universe` THEN bigbang()
> >>>
> >>>
> >>> Ash
> >>> www.ashleysheridan.co.uk
> >>>
> >>>
> >> any chance of writing the implementation of that bigbang() function?
> >>
> >
> > If nothing exists and a universe is created via a big bang... does it
> > make a sound? Can we realistically call it a big bang if it doesn't make
> > a sound? Couldn't we call it the big light show? But then again... if
> > nothing exists and a universe is created via a big light show... does it
> > matter? Can it be perceived? Is this just a proverbial pandrödinger's
> > box? You can't implement the bigbang() function if you don't exist.
> >
> > Cheers,
> > Rob.
> >
> The function doesn't say who's doing the creating, it just checks for
> the existence of the universe.

Lol, I agree, the function bigbang() doesn't need to be implemented (or it
could be empty if it needs to be there for this line to work), because by
definition, the universe must exist, if this statement is to exist.
Although it would be interesting to see an implementation of a simulation of
bigbang().
And, I would say there is a sound, even if no one is there to hear it,
assuming it to have happened. Also if there were no sound, there would be no
light show either, there would be nothing, which contradicts the assumption
that the big bang was there (exists)...

Guys, I think this is taking it a bit far...


Re: [PHP] A MySQL Question

2008-12-08 Thread German Geek
On Tue, Dec 9, 2008 at 3:51 PM, Micah Gersten <[EMAIL PROTECTED]> wrote:

> German Geek wrote:
> > On Tue, Dec 9, 2008 at 2:46 PM, Micah Gersten <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Robert Cummings wrote:
> > > On Tue, 2008-12-09 at 00:16 +, Nathan Rixham wrote:
> > >
> > >> Ashley Sheridan wrote:
> > >>
> > >>> On Mon, 2008-12-08 at 23:23 +, [EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]> wrote:
> > >>>
> > >>>> Presumable, the EXISTS sub-query can be optimized sometimes
> > to just stop processing the sub-query and kick things back out to
> > the outer query.
> > >>>>
> > >>>>
> > >>>>
> > >>>> IN has to process them all and find them all.
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>> Don't forget the special case use as well:
> > >>>
> > >>> IF NOT EXISTS `universe` THEN bigbang()
> > >>>
> > >>>
> > >>> Ash
> > >>> www.ashleysheridan.co.uk <http://www.ashleysheridan.co.uk>
> > >>>
> > >>>
> > >> any chance of writing the implementation of that bigbang()
> > function?
> > >>
> > >
> > > If nothing exists and a universe is created via a big bang...
> > does it
> > > make a sound? Can we realistically call it a big bang if it
> > doesn't make
> > > a sound? Couldn't we call it the big light show? But then
> > again... if
> > > nothing exists and a universe is created via a big light show...
> > does it
> > > matter? Can it be perceived? Is this just a proverbial
> > pandrödinger's
> > > box? You can't implement the bigbang() function if you don't exist.
> > >
> > > Cheers,
> > > Rob.
> > >
> > The function doesn't say who's doing the creating, it just checks for
> > the existence of the universe.
> >
> > Lol, I agree, the function bigbang() doesn't need to be implemented
> > (or it could be empty if it needs to be there for this line to work),
> > because by definition, the universe must exist, if this statement is
> > to exist.
> Who says this statement is run in this universe?  Who says it's not for
> a simulator?
> >
> > Guys, I think this is taking it a bit far...
>
> You new here? ;)
>
Yep. I'm new here. :)

OK, to take this even further then...
How about a start of a high level function:

function bigbang() {
  $elementsNecessaryForBang = God::createElements(); // have to get it from
somewhere, don't know how to get this just yet
  $particleSimulator = new ParticleSimulator($elementsNecessaryForBang);
  $particleSimulator->start();
  // ...
  return $universe;
}

Oh, I forgot. We're writing this in plain MySQL? Don't know how to even
start this... :) I guess this is a PHP List, so I guess it's safe to use
PHP, no? Sorry for stealing the thread...


Re: [PHP] Accounting component in PHP

2008-12-09 Thread German Geek
You can do raw queries also... Just makes trivial queries and your model (if
you believe in modelling) easier to manage. Believe me, I thought like you
did before using symfony.

On Tue, Dec 9, 2008 at 10:52 PM, altern <[EMAIL PROTECTED]> wrote:

>
> All my queries are complex. If I will use ORM, then I still will need
> another
> wrapper to create, for example template criteria objects. I have
> application
> that is very similar to billing system. Such type of applications
> definitely
> have other business logic levels in addition to ORM queries, as you might
> notice.
>
>
> Geek (de=German top level domain) wrote:
> >
> > You can do raw SQL queries with ORM as well, at least in symfony ;). An
> > ORM
> > makes other, rather trivial queries a whole lot easier though and a
> > framework like symfony makes development of generic requirements a lot
> > faster and cleaner.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20911661.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] A MySQL Question

2008-12-09 Thread German Geek
On Tue, Dec 9, 2008 at 10:49 PM, Yeti <[EMAIL PROTECTED]> wrote:

> As a matter of fact, in space you can't even scream.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> I don't know if there is a "better" or "best" solution to this, but an
infinite loop for something that is finite, I don't know...

I do like the stick whacking the drum part though. :)

And yes, you wouldnt hear anything in space, hadnt thought about that, so
you can argue that the big bang didnt make a noise because it wouldnt have
been hearable because there was nothing to carry the sound. For that matter
it wouldnt have been seeable either. Something being hearable or seeable is
different from someone/thing hearing or seeing it though. My point: Not
trying to make one, or any sense either, because im probably contradicting
myself here as are all of you, no offence.

However, I find the big bang theory more convincing than any 7 days creation
theory or things like that (sorry to all the religious people out there),
But then you can always ask what was before that and before that and so on.
But no one ever asks who or what created god in the first place, if s/he/it
exists. Was s/he/it always there? Well then one could argue that the
universe was always there too and there was no creation or big bang, or was
good there for infinity and after a few quadrillion years, s/he/it became so
bored and decided to make a big firework or only spend 7 days in creating
everything? 7 days is a horribly short time for such a task after an
infinite time of boredome. Maybe earth was always there (although this seems
unlikely too). But do we really know that? I mean, ive read it in a book and
learned it at school, but maybe we're all wrong and its all totally
different to what is expected. To me only one thing is clear: We will never
know how it all began, because a beginning of time and everything seems
illogical to me, because there must have been something before that.
Infinity, although to most not graspable seems a more graspable concept to
me than finity. Anybody agree or am i alone in this universe?

Sorry to go terribly off topic here...


[PHP] pear Mail/Mime problem on new Ubuntu Linux server

2008-12-09 Thread German Geek
Hi All,

Can someone think of a reason why when changing from a Windows 2003 Web
Edition server running PHP 5.2 to a Ubuntu machine, also with PHP 5.2 can
cause the following problem:

The emails sent from the server, which should be in HTML format (the client
wanted this specifically) now only show the plain text email, but only in
Outlook XP or 2003. The Outlook 2007 on my work machine receives it fine,
also my gmail account. Unfortunately, the client uses the Outlook version
with the problem.

Might it be the Unix newline characters?

My first suspicion was to blame M$ for letting Outlook check the headers for
example.com, postfix or Linux, but that might be a bit exajurated paranoia.
lol

Thanks for even reading this, even more for replying. :)

Tim


Re: [PHP] Re: file_exists and wildcard/regex

2008-12-09 Thread German Geek
On Wed, Dec 10, 2008 at 1:13 PM, Stut <[EMAIL PROTECTED]> wrote:

>
> On 9 Dec 2008, at 23:24, Daniel Kolbo wrote:
>
>  Maciek Sokolewicz wrote:
>>
>>> Daniel Kolbo wrote:
>>>
 What is the preferred method with php to test and see if a file
 [pattern] exists?

 For example, i only need to search in one directory, that may have any
 number of files named such as afile1.txt, afile2.txt, afile3.txt,   And
 also, bfile1.txt, bfile2.txt, bfile3.txt, ...
 I want to see if any such file 'family' exists.  That is, i want to see
 if there is any file named bfile[1-9][0-9]+.txt.  I don't care which bfile
 number exists, i just want to know if any bfile exists.

 I hope this is clear enough, if not let me know.

 thanks,
 dK


>>> glob()
>>>
>>> http://www.php.net/glob
>>>
>> How portable is glob?
>> How fast is glob?  Being that it searches through the entire filesystem,
>> this could potentially take a long time (like if  i have wildcards early in
>> the filepath pattern and lots of matches) correct?  If my file variations
>> (wildcards) are just at the end of of the filepaths and i don't have more
>> than 1000 files in the directory then will I most likely be 'alright' with
>> glob (in terms of time)?  I have probably spent more time now 'considering'
>> the time implications of glob, than glob actually would consume when
>> operating...
>>
>> Thanks for the quick response/solutions.
>> dK
>>
>
> Glob works on all platforms.
>
> Glob does suffer from performance issues above a certain number of files,
> and this can be system dependant. If you're unsure how many files it may
> return you'd be better using opendir/readdir.
>
> Not sure where you got the idea that glob searches the entire file system,
> but it's limited to either the current working directory or the directory
> you specify. So if your PHP file is in /var/www/htdocs and you do
> glob('*.txt') you'll get all .txt files in /var/www/htdocs. And if you do
> glob('/tmp/*.txt') you'll get all .txt files in /tmp.
>
> -Stut
>
> --
> http://stut.net/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I wrote my own little function for a regex pattern match on files:
class FileHandle {
public static function copyReg($srcDir, $destDir, $regEx, $mkdir =
false) {
  // ensure we have the right dir separator /(unix) \(win) and not at
the end
  $srcDir = rtrim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR,
$srcDir), DIRECTORY_SEPARATOR);
  $destDir = rtrim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR,
$destDir), DIRECTORY_SEPARATOR);
  //echo "DEST: ". $destDir ." END";
  if ($mkdir && !is_dir($destDir)) mkdir($destDir, 0777, true); //make
dir if not exists and mkdir
if ($handle = opendir($srcDir)) {
while (false !== ($file = readdir($handle))) {
//echo "$file\n";
preg_match($regEx, $file, $matches);
if ($file != '.' && $file != '..' && count($matches) > 0) {
  //print("$regEx $srcDir $file \n=".
print_r($matches,true));
copy($srcDir . DIRECTORY_SEPARATOR . $file,
$destDir . DIRECTORY_SEPARATOR . $file);
}
}
return true;
}
return false;
}
}

Hope that helps. Don't know how good this will perform.


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


[PHP] usort for sorting an array of objects

2008-12-09 Thread German Geek
Hi Guys,

I need to sort an array of objects. I found this ( at a url that didnt let
me send this msg... ) and I would know how to do it, but I believe there
might be a cleaner, more elegant way to do it. In Java, you just need to
implement the interface Comparable and provide a method called compareTo (as
far as i remember) and then you can use one of the many sorting algorithms
generically on objects that are comparable...

Anyway, I didn't find something like that for PHP. Since I'm using symfony,
I had a bit of a play with the objects at hand and simply did a
sort($arrayOfObjects) and it did sort them by the id. Just wondering where
it got the information on what to sort on (not quite) correctly for my case?

Thanks for your interest.

-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread German Geek
On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote:

> On 10 Dec 2008, at 04:15, German Geek wrote:
>
>> I need to sort an array of objects. I found this ( at a url that didnt let
>> me send this msg... ) and I would know how to do it, but I believe there
>> might be a cleaner, more elegant way to do it. In Java, you just need to
>> implement the interface Comparable and provide a method called compareTo
>> (as
>> far as i remember) and then you can use one of the many sorting algorithms
>> generically on objects that are comparable...
>>
>> Anyway, I didn't find something like that for PHP. Since I'm using
>> symfony,
>> I had a bit of a play with the objects at hand and simply did a
>> sort($arrayOfObjects) and it did sort them by the id. Just wondering where
>> it got the information on what to sort on (not quite) correctly for my
>> case?
>>
>
> I'm confused. The function you need is the one you mention in the subject.
> All you need to do is create a function that compares two of the objects, in
> whatever way you need it to, and returns -1, 0 or 1. The pass that to the
> usort function - it doesn't care what type of thing is in the array. Full
> details available at http://php.net/usort.



I just ment to say it would be nice to have it like in Java or C# where you
can implement an interface, called Comparable and define a function in the
class called compareTo which returns an integer smaller, equal or greater
than 0 by which elements can generically be sorted by in a collection. Since
PHP has arrays (hash maps) as the primary collection type, and they are very
good for storing sets or other collections, it would be nice to have a sort
function that would look, if the elements of the array have a compareTo
method (implement the Comparable interface), and if they do, then sort with
that. I find it a bit surprising that such a well designed programming
language doesn't have such a useful feature. I guess one could use one of
the gazillion libraries out there to do the same thing. Also, one could
argue that this further checking would slow down functions that are
primarily used for sorting strings. However, the answer could be also in the
ArrayObject class which is in php natively. Only it should implement all the
array functions that are there anyway, which shouldnt be too hard to do for
the PHP PL developers. Some more in depth documentation of that class would
also be helpful.

Anyway, I found a not perfect, but good enough solution:

Implement a static compare function in the class of the object and put a
function in my library, that is simply called myTools::sort that will get
the object class of the first element of the array (if there is one) and
sort according to the compare method implemented in that class (if it
exists), otherwise just use sort. The compare method takes the parameters as
self:

public class AClass { // implements Comparable {
  public static function compare(self $obj1, self $obj2) {
return strcmp($obj1->prop1, $obj2->prop1); // e.g.
  }
}

That way I will get an exception if there is an object in the array which
does not have that class, but i can live with that. At least i'll get an
exception and not another funny error, because the parameters are self,
right?

It might be better to define an interface called Comparable with that
method, but was not really necessary for my case.

Just a few thoughts to maybe improve PHP in the future. Hopefully there will
be a lot of interfaces and objects for collection types at some stage in PHP
natively, although that might clutter the namespace and could be realised
with libraries. What are your thoughts?

-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 6:43 AM, Robert Cummings <[EMAIL PROTECTED]>wrote:

> On Thu, 2008-12-11 at 01:31 +1300, German Geek wrote:
> > On Wed, Dec 10, 2008 at 10:27 PM, Stut <[EMAIL PROTECTED]> wrote:
> >
> > > On 10 Dec 2008, at 04:15, German Geek wrote:
> > >
> > >> I need to sort an array of objects. I found this ( at a url that didnt
> let
> > >> me send this msg... ) and I would know how to do it, but I believe
> there
> > >> might be a cleaner, more elegant way to do it. In Java, you just need
> to
> > >> implement the interface Comparable and provide a method called
> compareTo
> > >> (as
> > >> far as i remember) and then you can use one of the many sorting
> algorithms
> > >> generically on objects that are comparable...
> > >>
> > >> Anyway, I didn't find something like that for PHP. Since I'm using
> > >> symfony,
> > >> I had a bit of a play with the objects at hand and simply did a
> > >> sort($arrayOfObjects) and it did sort them by the id. Just wondering
> where
> > >> it got the information on what to sort on (not quite) correctly for my
> > >> case?
> > >>
> > >
> > > I'm confused. The function you need is the one you mention in the
> subject.
> > > All you need to do is create a function that compares two of the
> objects, in
> > > whatever way you need it to, and returns -1, 0 or 1. The pass that to
> the
> > > usort function - it doesn't care what type of thing is in the array.
> Full
> > > details available at http://php.net/usort.
> >
> >
> >
> > I just ment to say it would be nice to have it like in Java or C# where
> you
> > can implement an interface, called Comparable and define a function in
> the
> > class called compareTo which returns an integer smaller, equal or greater
> > than 0 by which elements can generically be sorted by in a collection.
> Since
> > PHP has arrays (hash maps) as the primary collection type, and they are
> very
> > good for storing sets or other collections, it would be nice to have a
> sort
> > function that would look, if the elements of the array have a compareTo
> > method (implement the Comparable interface), and if they do, then sort
> with
> > that. I find it a bit surprising that such a well designed programming
> > language doesn't have such a useful feature. I guess one could use one of
> > the gazillion libraries out there to do the same thing. Also, one could
> > argue that this further checking would slow down functions that are
> > primarily used for sorting strings. However, the answer could be also in
> the
> > ArrayObject class which is in php natively. Only it should implement all
> the
> > array functions that are there anyway, which shouldnt be too hard to do
> for
> > the PHP PL developers. Some more in depth documentation of that class
> would
> > also be helpful.
> >
> > Anyway, I found a not perfect, but good enough solution:
> >
> > Implement a static compare function in the class of the object and put a
> > function in my library, that is simply called myTools::sort that will get
> > the object class of the first element of the array (if there is one) and
> > sort according to the compare method implemented in that class (if it
> > exists), otherwise just use sort. The compare method takes the parameters
> as
> > self:
> >
> > public class AClass { // implements Comparable {
> >   public static function compare(self $obj1, self $obj2) {
> > return strcmp($obj1->prop1, $obj2->prop1); // e.g.
> >   }
> > }
> >
> > That way I will get an exception if there is an object in the array which
> > does not have that class, but i can live with that. At least i'll get an
> > exception and not another funny error, because the parameters are self,
> > right?
> >
> > It might be better to define an interface called Comparable with that
> > method, but was not really necessary for my case.
> >
> > Just a few thoughts to maybe improve PHP in the future. Hopefully there
> will
> > be a lot of interfaces and objects for collection types at some stage in
> PHP
> > natively, although that might clutter the namespace and could be realised
> > with libraries. What are your thoughts?
>
> You can already do what you want. Implement it yourself. Not everyone
> wants this level of cruft and inefficiency.


Inefficiency for me is when it takes longer to code. For one second of
coding time I can waste 1000ms of processing time without any cost. Think
about what a computer can do in 1000ms. Calling a function generically takes
next to nothing in processing time (maybe 0.5ms or less. In fact some db
queries take less than that in my experience...

-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] usort for sorting an array of objects

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 12:28 PM, <[EMAIL PROTECTED]> wrote:

>
> > Inefficiency for me is when it takes longer to code.
>
> How long can this take?

That's why i like PHP. It's very quick to do stuff in, even if arrays are
not always the ultimate data structure, they're easy to handle with all the
nice functions in PHP...

>
>
> Even if you go full-blown with an Interface and static methods that have to
> be fleshed out in the implementations, you're still talking about an hour or
> so.

Quit complaining and start typing.
> :-)


I wasn't complaining at all. In fact, it was a suggestion to think about. I
don't have a problem with someone proving me wrong. In fact, if i would
think I was always right, i wouldn't write to a mailing list to hear what
other people think. ;-)


> > PHP is a scripting language.
>
Well done. I wasn't aware of that :-)

>
> > Everytime the compiler has to parse the source.
>
> No.
>
> The source is compiled once, and your callback is a PHP function pointer
> passed down to the C function for usort.
>
> That C function has to call back out to the PHP function pointer.
>
> That is "slow" compared to a all native C, perhaps, but it's not
> re-compiling your PHP source function on every call to the compare function.
>
> Even if you are comparing across script calls, APC or ZendCache or similar
> will compile once.
>
> The slowness isn't even in the compiling anyway, really.  It's in hitting
> the disk drive to LOAD the PHP source.
>
> It's just as easy to cache the parsed byte-code as it is the source, and it
> saves a few more cycles, so the caches store the byte-code; But the real
> savings is not hitting the hard drive to get the PHP source.
>
> > You can not except true OOP performance.
>
> If you REALLY want performance, OOP has enough overhead that you can
> re-factor to strictly procedural or functional and squeeze out a bit more
> :-)
>
OOP has less overhead in development time, which is a lot more expensive
than processing time these days. The overhead is O(n). It depends more on
your algorithm than on the way you write functions or the PL i think. In
fact, in some cases the processing would be quicker to not write a function
for a few lines of code. I try to write everything in a function to make it
more readable and maintainable, because that is what really counts, i think.


>
> Not too many device drivers written in C++
>
For device drivers performance is more crucial than for end user
applications. Each ms or even ns you save in a device driver can save you a
multitude in an application (the worse the app code, the more important the
performance of the device driver).

>
>
> > OOP behavior is okay.
> > If performance is the main factor, an C extension will do that.
>
> If you're sorting anything large enough for performance to be the main
> factor, it probably belongs in a database, actually...

Yeah, agree. Whenever i can write a query for something, i do that instead.
In this particular case i had at hand however, it was a lot easier to do the
things i wanted when the data (after a rather complex query) is in memory.
Only maybe up to 20 records which shouldn't be too bad.

>
>
> I know somebody somewhere has some custom PHP extension to prove me wrong,
> but that's going to be the exception.

What is the exception? To prove you wrong or the PHP extension? :-)

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


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 1:59 PM, Stephen Johnson <[EMAIL PROTECTED]
> wrote:

> I think you want something like this :
> exec("convert -density 360x360 -enhance $pdfFile $pdfFile.gif");
>

Yes, that's how i did it here. Didn't find a better solution yet. Was
looking at the php module for imagemagick (imagick i believe), but that
seemed not quite there yet for deployment. Please advise if someone got that
working. Would prefer this over a shellexecute. You will need to install
imagemagick and i believe you also need ghostscript for this to work. You
can get both for linux and windows, free.

On debian and ubuntu and such:
apt-get install imagemagick gs


>
> On 12/10/08 4:48 PM, "Brian Dunning" <[EMAIL PROTECTED]> wrote:
>
> > I've spent most of the last week trying to get ImageMagick working on
> > my Windows PHP installation. I gather that since I'm going to be
> > converting PDFs to JPEGs, I need Ghostscript.
> >
> > Well, I've got ImageMagick installed: http://printhq2.com/info.php
> > I ran a Ghostscript installer, but it didn't seem to do very much.
> >
> > Some site advised me to test my installation like this:
> >  > echo "";
> > system("convert -version");
> > echo "";
> > ?>
> > But it just returns blank. Can anyone help me get ImageMagick working
> > on my server?
> >
> >
> > On Nov 20, 2008, at 4:41 PM, Stephen Johnson wrote:
> >
> >> No but you can use imagemagicks convert to convert the pdf to an
> >> image and
> >> then make a thumbnail of it.
> >
>
> --
> Stephen Johnson
> The Lone Coder
>
> http://www.ouradoptionblog.com
> *Join us on our adoption journey*
>
> [EMAIL PROTECTED]
> http://www.thelonecoder.com
>
> *Continuing the struggle against bad code*
> --
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] Re: converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 1:53 PM, Rene Veerman <[EMAIL PROTECTED]> wrote:

> Colin Guthrie wrote:
>
>> 'Twas brillig, and Rene Veerman at 10/12/08 23:03 did gyre and gimble:
>>
>>> Well, nowhere can i find the frame count being printed, but there _is_ a
>>> duration: hh:mm:ss:ms field outputted, and the updating line displays a
>>> time=seconds.ms (the time in the movie where the encoder is at).
>>>
>>> The question remains how to get at that updating output, with exec() you
>>> get the output after it's done completely.
>>> And there's no way to do partial conversions with ffmpeg, it's all in one
>>> or nothing..
>>>
>>
>> IIRC you can use popen and just read the output into PHP.
>>
>> http://uk.php.net/manual/en/function.popen.php
>>
>> That said, if I were you I'd do this system slightly differently. I'd do
>> the submissions via the web, but then do the encoding as a kind of daemon
>> process/cron job that runs on the server. This cron job would do the
>> encoding and update a db table periodically with progress. That way you can
>> have a page the user goes to that sees their "job progress".
>>
>> This way the user's browser will not time out and you wont use up apache
>> connections waiting for encodings and also you wont kill your server by
>> performing multiple encodes at the same time - with the cron job/daemon
>> approach you can control how many jobs are performed at the same time and
>> thus limit the load.
>>
>> Just some thoughts.
>>
>> Col
>>
>>
> Yep, this is already how it works.. Cron calls a php controller daemon
> script (if it aint runnin yet), which reads the various open tasks, and
> executes one task step (convert & import a single media file) at a time for
> each open task.
> It terminates after no more tasks have steps to do.
> The scripts executing the task update a status JSON file in the tasks'
> working directory, which is the only thing being read by the browser after
> it's kicked off the import process by calling the daemon server with the
> list of files to import.
>
> i've taken a look at popen() and think i can indeed get it to work with
> that..
> i'll let you all know in this thread where to view a demo, when it works :)
>

Cool, would like to see it in action.
In case you haven't thought of this and it's relevant:
If ffmpeg is writing out a file and you can estimate the final size, you
could check the file size, if it's growing that is, and compare it to the
estimated final size to show the progress. Maybe not the best solution but
if there is nothing else.

If you don't mind, i would like to know some good parameters for ffmpeg to
convert video files to flv format. Might use it in the future.


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


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] Re: converting a vid with ffmpeg - howto do progress bars?

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 2:27 PM, Rene Veerman <[EMAIL PROTECTED]> wrote:

> German Geek wrote:
>
>> On Thu, Dec 11, 2008 at 1:53 PM, Rene Veerman <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:
>>
>>Colin Guthrie wrote:
>>
>>'Twas brillig, and Rene Veerman at 10/12/08 23:03 did gyre and
>>gimble:
>>
>>Well, nowhere can i find the frame count being printed,
>>but there _is_ a duration: hh:mm:ss:ms field outputted,
>>and the updating line displays a time=seconds.ms
>><http://seconds.ms> (the time in the movie where the
>>
>>encoder is at).
>>
>>The question remains how to get at that updating output,
>>with exec() you get the output after it's done completely.
>>And there's no way to do partial conversions with ffmpeg,
>>it's all in one or nothing..
>>
>>
>>IIRC you can use popen and just read the output into PHP.
>>
>>http://uk.php.net/manual/en/function.popen.php
>>
>>That said, if I were you I'd do this system slightly
>>differently. I'd do the submissions via the web, but then do
>>the encoding as a kind of daemon process/cron job that runs on
>>the server. This cron job would do the encoding and update a
>>db table periodically with progress. That way you can have a
>>page the user goes to that sees their "job progress".
>>
>>This way the user's browser will not time out and you wont use
>>up apache connections waiting for encodings and also you wont
>>kill your server by performing multiple encodes at the same
>>time - with the cron job/daemon approach you can control how
>>many jobs are performed at the same time and thus limit the load.
>>
>>Just some thoughts.
>>
>>Col
>>
>>
>>Yep, this is already how it works.. Cron calls a php controller
>>daemon script (if it aint runnin yet), which reads the various
>>open tasks, and executes one task step (convert & import a single
>>media file) at a time for each open task.
>>It terminates after no more tasks have steps to do.
>>The scripts executing the task update a status JSON file in the
>>tasks' working directory, which is the only thing being read by
>>the browser after it's kicked off the import process by calling
>>the daemon server with the list of files to import.
>>
>>i've taken a look at popen() and think i can indeed get it to work
>>with that..
>>i'll let you all know in this thread where to view a demo, when it
>>works :)
>>
>>
>> Cool, would like to see it in action.
>> In case you haven't thought of this and it's relevant:
>> If ffmpeg is writing out a file and you can estimate the final size, you
>> could check the file size, if it's growing that is, and compare it to the
>> estimated final size to show the progress. Maybe not the best solution but
>> if there is nothing else.
>>
>>  i've thought of it, and considered it too random to even try to estimate
> ;)

OK. So you have tried converting a couple of vids and the resulting file
size is always random? Surely there must be some kind of relation to the
input file size, the transcode parameters and the output file size. Of
course it also depends on the nature of the video but you could also take
into account the file size and the time it took to get to that file size
(during the process) in relation to the input file size.

>
>  If you don't mind, i would like to know some good parameters for ffmpeg to
>> convert video files to flv format. Might use it in the future.
>>
>>
>
>   $cmd = 'nice -n 19 ffmpeg -i "'.$sourcePath.'" -b 500 -acodec mp3 -ab
> 192 -ar 22050 -y "'.$destination.'"';
>
> that's what i'm using now. it spits out files larger than the divx
> originals that i'm using for testing purposes.
> -b  is used to set the quality and size of the output flv
>
> usefull too;
> http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

Thanks.


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] array_intersect question

2008-12-10 Thread German Geek
On Tue, Dec 2, 2008 at 11:06 PM, Andrej Kastrin <[EMAIL PROTECTED]>wrote:

> It works like a charm.
>
> Thanks, Andrej
>
> Tim | iHostNZ wrote:
>
>> I know there must be a more elegant way with array_reduce or something,
>> but
>> I would simply write a function called
>>
>> function array_intersect_m($m_array) {
>>  $intersection = $m_array[0];
>>  for ($i=1; $i < count($m_array); $i++) {
>>$intersection = array_intersect($m_array[$i], $intersection);
>>  }
>>  return $intersection;
>> }
>>
>> and put that into my library. O and while i'm at it, the array_reduce way
>> would prob be:
>> $m_array =
>> array(array("green","red","blue"),array("green","yellow","red"),array("green","red","purple"),array("green","red","yellow"));
>> array_reduce($m_array, 'array_intersect');
>>
>
I tried this now with array_reduce and it didn't work as i expected. Can
anyone tell me why?
It says argument #1 to array_intersect is not an array, although i have an
array of arrays. Also tried providing $arrayOfArrays[0] as the third
parameter to array_reduce which had the same error.

Thanks,
Tim


Re: [PHP] Need help on MySQL query

2008-12-10 Thread German Geek
On Thu, Dec 11, 2008 at 4:52 PM, Rahat Bashir <[EMAIL PROTECTED]>wrote:

> Hi Experts,
>
> EID Mubarak to all.
>
> I need your help on writing a MySQL query.
>
> Scenario:
>
> CREATE TABLE transaction
> (
> `id` int NOT NULL ATUTO INCREMENT,
> `date` datetime  NOT NULL,
> `withdrawn` double (12,2) NULL,
> `deposit` double (12,2) NULL
> );
>
> SELECT * FROM transaction;


SELECT *,  deposit-withdrawn AS balance FROM transaction

Although i would suggest a transaction table to only have positive and
negative balances. Then you can do all sorts of things with it like get the
sum of all transactions a lot easier etc.

e.g.

SELECT SUM(balance) AS user_balance FROM transaction WHERE user_id=1

if you have a user id e.g. Are you working for a bank? :-)

>
>
> id  date
> withdrawn  deposit
> --
> --- --
> 1   2008-12-01 00:00:00
> NULL1.00
> 2   2008-12-02 00:00:00 4000.00
>NULL
> 3   2008-12-04 00:00:00 2000.00
>NULL
> 4   2008-12-05 00:00:00
> NULL4500.00
> 5   2008-12-06 00:00:00 500.00
> 1500.00
>
> The above is all I have. I want to make query which should output an extra
> calculated column named "balance", something like following:
>
> Expected output from query:
> id  date
> withdrawn  depositbalance
> --
> --- -- -
> 1   2008-12-01 00:00:00
> NULL1.00 1.00
> 2   2008-12-02 00:00:00 4000.00
>NULL  6000.00
> 3   2008-12-04 00:00:00 2000.00
>NULL  4000.00
> 4   2008-12-05 00:00:00
> NULL4500.00   8500.00
> 5   2008-12-06 00:00:00 500.00
> 1500.00   9500.00
>
> Thanks in advance
>
>
> --
> Rahat Bashir
> Dhaka, Bangladesh
>


Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread German Geek
On Fri, Dec 12, 2008 at 7:03 AM, tedd  wrote:

> At 11:23 AM -0500 12/11/08, Robert Cummings wrote:
>
>> On Thu, 2008-12-11 at 11:05 -0500, tedd wrote:
>>  > When I say "Hack a site" I mean to do something to get the site to
>>
>>>  provide an unintended result as  expected by the author.
>>>
>>>  Much like using CSS "Hacks" to get browsers to do something that was
>>>  not intended by the original designers.
>>>
>>>  On the other hand, my understanding of "cracking" means to "crack"
>>>  some type of encryption. Thus, the reason why I did not say "cracking
>>>  the site" instead of "hacking the site".
>>>
>>
>> Cracking is not just about encryption. It's about bypassing any kind of
>> measure put in place to prevent someone from doing something. Hacking on
>> the other hand does not embody this principle, although hacking may be
>> employed to achieve cracking. Just because pop culture is completely
>> ignorant to the difference, doesn't mean you as a member of the
>> community need to jump on board and bleat like a sheep. If you intend to
>> misuse hacker, then you should at least provide more detail such as
>> white-, grey-, or black-hat.
>>
>> Cheers,
>> Rob.
>>
>
>
> Okay, I shall adjust my fracking terminology. :-)
>
> Cheers,
>
> tedd
>

Cracking to me is when someone uses an already existing hack to use it for
their own gain in a malicious way to someone else.
Hacking is finding new security holes or problems with some software to fix
the security holes, or just for fun without causing any demage or revealing
sensitive information.
A hacker to me, is an admirable person, who can find new security issues.
A cracker to me, is someone exploiting hacks already in existence.


Re: [PHP] Need a brain to bounce some Mysql/DB thoughts off of!!

2008-12-11 Thread German Geek
This list seems to be turning into a MySQL list with a few PHP questions...
Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Dec 12, 2008 at 1:53 PM, bruce  wrote:

> Hi guys.
>
> Architecting an app that's going to have users interacting with different
> levels of the db/tbls, and trying to figure out a few things.
>
> The highlevel layout looks like:
>  collegeTBL
>  deptTBL
>
>  with ->collegeTBL.id = deptTBL.colID
>
> I also have a status tbl for each collegeTBL/deptTBL
>
>  college_statusTBL
>   userID
>   collegeID
>
>  dept_statusTBL
>   userID
>   deptID
>
>  with:
>  collegeTBL.id=college_statusTBL.collegeID
>  deptTBL.id=dept_statusTBL.deptID
>
> So I limk the statusTBLs to the college/dept TBLs...
>
> This is due to the fact that a user can elect to work on either a college,
> or a given dept of the college.
>
> I'm struggling with a good/best way to figure out how to develop a query to
> determine what level of a college, (if any) a user has elected to work
> with.
>
> I can do a multiple join across the collegeTBL/deptTBL, and the statusTBLs,
> but this simply gets a large tbl, and I'd have to then parse the results...
> I'm trying to figure out if there's a better way, with a single query. The
> query would look at the college(status), and then at the dept(status) to
> determine what level (if any ) the user has selected.
>
> I've got a mysql layout of the various tbls, and inserts if anyone's
> interested in helping me shake my mind out on this...
>
> thanks
>
> -bruce
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Need a brain to bounce some Mysql/DB thoughts off of!!

2008-12-11 Thread German Geek
OK, i give u that, Rob. :-) I might just ask MySQL questions here, if i have
some.

I guess, if people get more responses here, it shows that this mailing list
is superior (no offence to the MySQL list :-P ).

Tim

On Fri, Dec 12, 2008 at 4:04 PM, Robert Cummings wrote:

> It's Christmas... the season of giving and tolerance :|
>
>
> On Fri, 2008-12-12 at 13:56 +1300, German Geek wrote:
> > This list seems to be turning into a MySQL list with a few PHP
> questions...
> > Tim-Hinnerk Heuer
> >
> > http://www.ihostnz.com
> >
> >
> > On Fri, Dec 12, 2008 at 1:53 PM, bruce  wrote:
> >
> > > Hi guys.
> > >
> > > Architecting an app that's going to have users interacting with
> different
> > > levels of the db/tbls, and trying to figure out a few things.
> > >
> > > The highlevel layout looks like:
> > >  collegeTBL
> > >  deptTBL
> > >
> > >  with ->collegeTBL.id = deptTBL.colID
> > >
> > > I also have a status tbl for each collegeTBL/deptTBL
> > >
> > >  college_statusTBL
> > >   userID
> > >   collegeID
> > >
> > >  dept_statusTBL
> > >   userID
> > >   deptID
> > >
> > >  with:
> > >  collegeTBL.id=college_statusTBL.collegeID
> > >  deptTBL.id=dept_statusTBL.deptID
> > >
> > > So I limk the statusTBLs to the college/dept TBLs...
> > >
> > > This is due to the fact that a user can elect to work on either a
> college,
> > > or a given dept of the college.
> > >
> > > I'm struggling with a good/best way to figure out how to develop a
> query to
> > > determine what level of a college, (if any) a user has elected to work
> > > with.
> > >
> > > I can do a multiple join across the collegeTBL/deptTBL, and the
> statusTBLs,
> > > but this simply gets a large tbl, and I'd have to then parse the
> results...
> > > I'm trying to figure out if there's a better way, with a single query.
> The
> > > query would look at the college(status), and then at the dept(status)
> to
> > > determine what level (if any ) the user has selected.
> > >
> > > I've got a mysql layout of the various tbls, and inserts if anyone's
> > > interested in helping me shake my mind out on this...
> > >
> > > thanks
> > >
> > > -bruce
> > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>


Re: [PHP] php client

2008-12-14 Thread German Geek
On Mon, Dec 15, 2008 at 11:07 AM, Stephen  wrote:

> idan72 wrote:
>
>> Hi,
>>
>> I am new to PHP.
>> I want to write a web client in PHP that will data to a server written in
>> Java.
>> I want that the client will send an object to the server.
>
> Don't know if that would be easy in PHP. I presume you are using RMI??

>
>>
>> What is the best way to do that?
>> Where can I find an example for doing that ?
>>
>>
> JAVA is on the client side. That is, it runs in the users browser.
>

This is not necessarily true. There are Java Applets that are run on the
client. But there are also Java Server Pages (JSP) and Java is designed to
run on servers as well as clients. Javascript (which is totally different!)
always runs on the client.

You could even write a web (or any) server in Java, because it supports
sockets, RMI and even CORBA ;). Ever heard of Java IEEE?



>
> PHP is on the server side, and there is no direct interaction between PHP
> and the user.


You can also write applications in PHP that you can run on a client
(although you would need PHP installed). There are even gui frameworks for
PHP ( http://gtk.php.net/ ).


>
> It seems from what you write that you need a "form" in a web page, and a
> PHP script to process the data the user enters and submits from the form.
> You may not need JAVA at all.
>
> If this is what you want to go, Google, "PHP forms"
>
> Stephen
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] Good PHP book?

2008-12-14 Thread German Geek
The best book is php.net, if you already know a programming language ;-).
Otherwise Ashley is probably right. I haven't read any books on php, got all
the info off the web, but it's still my main language atm.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 15, 2008 at 11:48 AM, Ashley Sheridan
wrote:

> On Sun, 2008-12-14 at 16:33 -0600, jeffery harris wrote:
> > Hi guys/gals. I'm a first time user. Does anyone know of a good php book?
> >
> >
> >
> I tend to trust O'Reilly books a lot for all things programming,
> although I learnt largely with 'PHP, Apache, MySQL Web Development' from
> WROX.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Chrome 1.0 released

2008-12-14 Thread German Geek
Conspiracy against M$? I thought they were conspiring against the world :-)

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 15, 2008 at 2:22 PM, Yeti  wrote:

> It more and more seems like a conspiracy against M$ to me. A company
> trying to make up its own standards every once in a while, how can
> that be wrong?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Create unique non-autoincrement key for 700,000 records?

2008-12-15 Thread German Geek
If i had to guess, it would be the column/field in the table that has the
autoincrement value.
Tim-Hinnerk Heuer

http://www.ihostnz.com


On Tue, Dec 16, 2008 at 5:29 PM, Rob Gould  wrote:

>
>
>  update mytable set hash_field = md5(AutoIdField + unix_timestamp())
>
> I _think_ I understand that - - - - but what does the "AutoldField"
> variable mean?
>
>
>
>
>
> On Monday, December 15, 2008, at 09:37PM, "Bastien Koert" <
> phps...@gmail.com> wrote:
> >On Mon, Dec 15, 2008 at 9:29 PM, Rob Gould  wrote:
> >
> >> I have a mySQL database with 700,000 records in it, which are presently
> >> keyed with an "auto-increment" field.
> >>
> >> What I'd like to do is create another field with a field where each and
> >> every record number has a unique keyvalue. Example:  "su5e23vlskd" for
> >> records 1, and "34fdfdsglkdj4" for record 2.  All that matters is that
> it's
> >> unique, and isn't a number that can be guessed or an "autoincrement"
> number,
> >> where a hacker can just figure out the keyvalue by incrementing numbers.
>  It
> >> doesn't matter to me if each keyvalue field is just numbers, or a
> >> number/letter combination - - - all that matters is that each keyvalue
> field
> >> is unique.  Is there an automatic way that mySQL could do that, or would
> I
> >> need to write a php script to somehow go through each record and create
> this
> >> unique value?
> >>
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >update mytable set hash_field = md5(AutoIdField + unix_timestamp())
> >
> >--
> >
> >Bastien
> >
> >Cat, the other other white meat
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] SimpleXML - issue with getting data out of the object returned

2008-12-18 Thread German Geek
Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Dec 19, 2008 at 3:50 PM, Dan Joseph  wrote:

> Hi,
>
> I have a basic XML document that I am grabbing with
> simplexml_load_string(),
> here is the print_r:
>
> SimpleXMLElement Object
> (
>[Package] => SimpleXMLElement Object
>(
>[PackageID] => 804
>[PackageName] => Silver
>[BandwidthGB] => 20
>[WebStorageMB] => 5120
>[DBStorageMB] => 250
>[POPMailBoxes] => 50
>[WebStorageUnits] => 5
>[BandwidthUnits] => 1
>[DBStorageUnits] => 1
>[POPUnits] => 5
>[DomainHeaders] => 50
>[DBType] => MSSQL
>[OSType] => Windows
>[Enabled] => True
>)
>
>[Count] => 1
> )
>
> When I try and access $x->Package->PackageID I don't get 804, I get:
>
> SimpleXMLElement Object
>(
>[0] => 804
>)
>
Had that problem before:
$val = (string) $x->Package->PackageID;
or
$val = (int) $x->Package->PackageID;

or whatever type you want. ;)

>
> Could someone tell me how I just get the value 804 out of there?
>
> --
> -Dan Joseph
>
> www.canishosting.com - Plans start @ $1.99/month.
>
> "Build a man a fire, and he will be warm for the rest of the day.
> Light a man on fire, and will be warm for the rest of his life."
>


Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
$users is an array and you are trying to simply put it in a string. $x seems
to be undefined ergo it's not printing anything. If 'U' is the index in the
array for your variable, use the '.' operator to concatenate strings:

echo "
   
  '" . $users[$x]['U'] ."'
   ";

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 10:44 AM, MikeP  wrote:

> Hello,
> I am trying to output the value of the following:($x is an int incremented
> by a for statement.
>echo "
>
>   '$users[$x][U]'
>";
>
> I have tried putting the quotes all over and all I get is:
> 'Array[U]'.
>
> What am I doing wrong.
> Thanks
> Mike
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
OK. I would think it uses more memory then, but doubt it would be slower.
Isnt the output buffered in memory anyway though in PHP? Surely the buffer
is bigger than 100 bytes (which is about the length of this string). So one
way or the other, the memory is used.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 11:12 AM, Marc Steinert  wrote:

> German Geek schrieb:
>
>> Why is the first method faster and uses less memory?
>>
>>
>>
> Because the concatenation operator first reassembles a new string, stores
> it in memory then passes this newly created string to the echo function, if
> I'm not misstaken.
>
>
> --
> http://bithub.net/
> Synchronize and share your files over the web for free
>
>


Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
Why is the first method faster and uses less memory?

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 10:59 AM, Marc Steinert  wrote:

> MikeP schrieb:
>
>> I have tried putting the quotes all over and all I get is:
>> 'Array[U]'.
>>
>>
>>
> Try to avoid accessing the two-dimensional array $users inside a string.
> Use echo's ability to accept multiple parameters:
>
> echo '', $users[$x]['U'], '';
>
> Or by concating the string with the .-Operator:
>
> echo ''.$users[$x]['U'].'';
>
> The first method is faster and needs less memory.
>
> --
> http://bithub.net/
> Synchronize and share your files over the web for free
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Variable as an index

2008-12-21 Thread German Geek
Yes, i agree with this. Even if it takes a few nano seconds more to write
out more understandable code, it's worth doing it because code management is
more important than sqeezing out the last nano second. And then also an
$var = "Hello";
echo "$val World";

has less characters than and is more readable than

$var = "Hello";
echo $var ." World";

So it would take maybe a few nano seconds less to read it from the hard
drive. And we all know that disk I/O is more expensive than pushing around
variables in main memory in terms of time. And RAM is soo cheap these days.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Dec 22, 2008 at 12:50 PM, Anthony Gentile wrote:

> True, it might mean the very slightest in milliseconds...depending on what
> you're doing/hardware. However, no harm in understanding the difference/how
> it works.
> Many will code echo "Hello World" and echo 'Hello World'; and never know
> the
> difference, I just happen to think being aware of the details will help for
> the long term programmer.
> Since, I brought it up, I'll go ahead and give another example. Ternaries
> that make a lot of people feel awesome because a lot is being accomplished
> in one line are also more opcodes than their if-else statement
> equivalents...and often times can be more confusing to future maintainers
> of
> the code.
>
> Anthony Gentile
>
>
>
> On Sun, Dec 21, 2008 at 6:20 PM, Chris  wrote:
>
> > Anthony Gentile wrote:
> >
> >> for e.g.
> >> $var = 'world';
> >> echo "hello $var";
> >> vs
> >> echo 'hello '.$var;
> >>
> >> The first uses twice as many opcodes as compared to the second. The
> first
> >> is
> >> init a string and adding to it the first part(string) and then the
> second
> >> part (var); once completed it can echo it out. The second is simply two
> >> opcodes, a concatenate and an echo. Interpolation.
> >>
> >
> > I'd call this a micro-optimization. If changing this causes that much of
> a
> > difference in your script, wow - you're way ahead of the rest of us.
> >
> >
> >
> http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html
> >
> > http://www.phpbench.com/
> >
> > --
> > Postgresql & php tutorials
> > http://www.designmagick.com/
> >
> >
>


[PHP] shell_exec seems to hang other web requests while running convert

2008-12-22 Thread German Geek
Hi All,

The following problem:

Our client is converting pdfs to images with a web interface. At the moment
I'm using convert from imagemagick with shell_exec (i know i could use the
imagick module, but this would require quite a bit of recoding and time at
the moment, it was originally running on a windows machine and i couldnt get
the imagick module working on that).

Is there a quick way to give other web requests to the web server a higher
priority than this process? It can take quite a while to convert 100 pdf
pages to images in high res with convert. At the moment only 3 images at a
time are converted with some crazy ajax logic. But still while these 3
images are converted (can take 20-30 seconds) other requests seem to hang
until convert is finished. I know, i can put a & at the end of the command
line but then they wouldnt know when the process is actually finished.

The server is an ubuntu server with the latest release. It's got Apache:
Apache/2.2.8 (Ubuntu) mod_mono/2.0 PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch
mod_ssl/2.2.8 OpenSSL/0.9.8g Server at 208.79.206.58 Port 80

Please help. This is rather urgent and needs to be working properly
preferably before xmas. Anyway, merry xmas to everyone in case i forget to
say that later :-).

Tim-Hinnerk Heuer

http://www.ihostnz.com


Re: [PHP] shell_exec seems to hang other web requests while running convert

2008-12-22 Thread German Geek
cron is a good idea, havent thought about that. One could use the nice
program then to give it the lowest priority, because other requests are more
important than this and another server gives the issue of transfering files
back and forth. Another soln would be to run it with & in the background
(with nice) and then check if the file(s) exist on ajax calls to give
feedback, this might actually be easier to implement.

Anyway, we will fix the issue later now. Thanks.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Tue, Dec 23, 2008 at 7:21 PM, Nathan Nobbe wrote:

> On Mon, Dec 22, 2008 at 9:06 PM, German Geek  wrote:
>
>> Hi All,
>>
>> The following problem:
>>
>> Our client is converting pdfs to images with a web interface. At the
>> moment
>> I'm using convert from imagemagick with shell_exec (i know i could use the
>> imagick module, but this would require quite a bit of recoding and time at
>> the moment, it was originally running on a windows machine and i couldnt
>> get
>> the imagick module working on that).
>
>
> wow, i totally here you on the we cant change our imagemagick setup right
> now ;)
>
> But still while these 3
>> images are converted (can take 20-30 seconds) other requests seem to hang
>> until convert is finished. I know, i can put a & at the end of the command
>> line but then they wouldnt know when the process is actually finished.
>
>
> its very common to treat objectives which take more time to complete in an
> asynchronous manner.  typically the http request will place a 'command' into
> a queue, which is picked up by a cron job.  then the user is notified upon
> completion by an email or some other web page, which they can go to review
> at a later time.
>
> this will not help your server load at all however, if youve only got 1
> box.  the cron will be running and eating juice that the webserver would
> like to have.  best bet is to scale out by tossing another server in the mix
> to handle the imagemagick stuff.  whether or not you want to keep things
> real-time or move to a cron-based solution is up to you.
>
> -nathan
>
>


Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-22 Thread German Geek
agree, ++$i wont save u nething, it just means that the variable is
incremented after it is used:

$i = 0;
while ($i < 4) echo $i++;

will output
0123

while

$i = 0;
while ($i < 4) echo ++$i;

will output
1234

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Tue, Dec 23, 2008 at 7:25 PM, Nathan Nobbe wrote:

> On Mon, Dec 22, 2008 at 3:10 PM, Clancy  wrote:
>
> > On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote:
> > 
> > >I'd call this a micro-optimization. If changing this causes that much of
> > >a difference in your script, wow - you're way ahead of the rest of us.
> >
> > Schlossnagle (in "Advanced PHP Programming") advises:
> >
> > $i = 0; while ($i < $j)
> >{
> >
> >++$i;
> >}
> >
> > rather than:
> >
> > $i = 0; while ($i < $j)
> >{
> >...
> >$i++;
> >}
> >
> > as the former apparently uses less memory references.  However I find it
> > very hard to
> > believe that the difference would ever show up in the real world.
>
>
> nonsense, some college kid is going to put ++$i on a test to try an impress
> the professor when the semantics call for $i++ :D
>
> -nathan
> p.s.
> in case you couldnt tell; been there, done that. lol
>


Re: [PHP] shell_exec seems to hang other web requests while running convert

2008-12-23 Thread German Geek
We can live with the fact that it will take a little longer to process the
images. The image processing is only done by 2 people, about once a month,
just to save them time (they would do it with photoshop otherwise and it is
really boring and time consuming). In fact, i might set up an automatic
email when its finished. :-)

In the future it might become an issue when people can edit their own
ebooks. This project dates back to 1999, so a lot of it is legacy (a binary
page definition data format...). We're thinking of moving to swf pages
instead of images, as they currently are, that will reduce the time to be
taken to convert a pdf by thousands and would increase the quality and
reduce download times for end users, but it will take time to develop which
is not at hand atm.

We have been thinking about scaling issues as well for quite some time
now...
It was hard enough to get them to move to Linux, since i work in a .NET
shop...
Setting up load balancing is not a trivial task though and expensive to
host. I'm the main software developer on this project and am too busy adding
features and debugging ActionScript, C++ and PHP code to do that as well.

Thanks for your thoughts though.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Tue, Dec 23, 2008 at 7:41 PM, Nathan Nobbe wrote:

> On Mon, Dec 22, 2008 at 11:34 PM, German Geek  wrote:
>
>> cron is a good idea, havent thought about that. One could use the nice
>> program then to give it the lowest priority, because other requests are more
>> important than this and another server gives the issue of transfering files
>> back and forth. Another soln would be to run it with & in the background
>> (with nice) and then check if the file(s) exist on ajax calls to give
>> feedback, this might actually be easier to implement.
>
>
> nice'ing the process is a good idea, however, youll only prolong the time
> it will take to accomplish those img manipulation tasks, and soon you'll
> find yourself w/ a nice little backlog on your hands.
>
> what sounds to me to be the larger issue is pushing the limit on a single
> box.  in order to scale, youll need to spread the load somehow.  you can
> dodge the bullet now, but it will be back, if your sites popularity is
> growing.
>
> just my 2c
>
> -nathan
>
>


Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread German Geek
oops, yes of course lol
Tim-Hinnerk Heuer

http://www.ihostnz.com


On Tue, Dec 23, 2008 at 7:43 PM, Lars Torben Wilson wrote:

> 2008/12/22 German Geek :
> > agree, ++$i wont save u nething, it just means that the variable is
> > incremented after it is used:
>
> You meant ". . .before it is used:", right?
>
>
> Torben
>
> > $i = 0;
> > while ($i < 4) echo $i++;
> >
> > will output
> > 0123
> >
> > while
> >
> > $i = 0;
> > while ($i < 4) echo ++$i;
> >
> > will output
> > 1234
> >
> > Tim-Hinnerk Heuer
> >
> > http://www.ihostnz.com
> >
> >
> > On Tue, Dec 23, 2008 at 7:25 PM, Nathan Nobbe  >wrote:
> >
> >> On Mon, Dec 22, 2008 at 3:10 PM, Clancy  wrote:
> >>
> >> > On Mon, 22 Dec 2008 10:20:09 +1100, dmag...@gmail.com (Chris) wrote:
> >> > 
> >> > >I'd call this a micro-optimization. If changing this causes that much
> of
> >> > >a difference in your script, wow - you're way ahead of the rest of
> us.
> >> >
> >> > Schlossnagle (in "Advanced PHP Programming") advises:
> >> >
> >> > $i = 0; while ($i < $j)
> >> >{
> >> >
> >> >++$i;
> >> >}
> >> >
> >> > rather than:
> >> >
> >> > $i = 0; while ($i < $j)
> >> >{
> >> >...
> >> >$i++;
> >> >}
> >> >
> >> > as the former apparently uses less memory references.  However I find
> it
> >> > very hard to
> >> > believe that the difference would ever show up in the real world.
> >>
> >>
> >> nonsense, some college kid is going to put ++$i on a test to try an
> impress
> >> the professor when the semantics call for $i++ :D
> >>
> >> -nathan
> >> p.s.
> >> in case you couldnt tell; been there, done that. lol
> >>
> >
>
>
>
> --
> Torben Wilson 
>


Re: [PHP] eof bof in php

2008-12-23 Thread German Geek
Totally agree. Whenever i can i put html outside of php tags mainly because
the code gets more readable because in eclipse u get syntax highlighting
etc.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Wed, Dec 24, 2008 at 4:13 AM, tedd  wrote:

> At 2:21 PM -0500 12/22/08, Anthony Gentile wrote:
>
>> I would argue it is better practice as:
>>
>> 
>>
>> than
>>
>> > echo "Hello World";
>> ?>
>> Anthony Gentile
>>
>>
> Certainly, but all you have done here is to move your  to different
> places.
>
> There is a threshold one reaches in deciding where is the "best" place to
> put the "" -- it's a personal choice.
>
> With me, a one liner is sufficient for me to use:
>
> 
>
> For more than that, I usually:
>
> ?>
>
> html
>
> 
> I use heredoc for email text, but not for html. I do this primarily because
> I like the way my editor works for showing paired tags and braces. It makes
> it easy for me to check tag pairing.
>
>
> Cheers,
>
> tedd
>
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] MERRY XMAS

2008-12-23 Thread German Geek
Merry xmas to everyone! Thanks for the support and fun discussions.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


[PHP] PHP Linux/Windows Outlook 2003 HTML email problem

2009-02-01 Thread German Geek
Hi All,

We've got a problem with our Ubuntu Linux machine sending HTML emails to
Outlook 2003:

It's an Ubuntu Server (uname -a
Linux CDR2-221 2.6.24-19-server #1 SMP Wed Jun 18 15:18:00 UTC 2008 i686
GNU/Linux)

with the newest version of Postfix installed as the Mail server.

Unfortunately, all emails sent as HTML, using the PEAR library for sending
email like so:

  public static function sendEmail($fromEmail, $recipientsEmails, $subject,
$txtBody, $htmlBody = null, $ccEmails = null) {
require_once 'Mail.php';
require_once 'Mail/mime.php';

$message = new Mail_mime();
$message->setTXTBody($txtBody);
if (!$htmlBody) $htmlBody = str_replace("\n", "\n", $txtBody);
$message->setHTMLBody($htmlBody);
$message->setFrom($fromEmail);
if ($ccEmails) {
  if (!is_array($ccEmails)) $ccEmails = array($ccEmails);
  foreach ($ccEmails as $cc) {
$message->addCc($cc);
  }
}
//$message->addCc("m...@insiteorg.com");
$message->setSubject($subject);

$body = $message->get();
$headers = $message->headers();

$mail = Mail::factory("mail");
if (!is_array($recipientsEmails)) $recipientsEmails =
array($recipientsEmails);
foreach ($recipientsEmails as $mailto) {
  $mail->send($mailto, $headers, $body);
}
  }

arrive with only the plaintext part in Outlook 2003 (and only in Outlook
2003). All other email programs (Outlook 2007 e.g.) seem to work fine with
the formatting.

This only started happening on the Linux machine and works fine when emails
are sent by a windows host or another mail server from the ISP. So i suspect
it must be the setup of Postfix on that machine that is not quite correct.

Other than that, i get the following messages from PHP, apparently the PEAR
library has some (strinct) warnings which i thought should be ok:

*Strict Standards*: Assigning the return value of new by reference is
deprecated in */usr/share/php/Mail.php* on line *154*

*Strict Standards*: Assigning the return value of new by reference is
deprecated in */usr/share/php/PEAR.php* on line *569*

*Strict Standards*: Assigning the return value of new by reference is
deprecated in */usr/share/php/PEAR.php* on line *572*

*Strict Standards*: Non-static method Mail::factory() should not be called
statically in */home/magsbyme/www/
ljhooker.ddm.magsbyme.com/lib/myTools.class.php* on line *1035*

*Strict Standards*: Non-static method PEAR::isError() should not be called
statically, assuming $this from incompatible context in *
/usr/share/php/Mail.php* on line *156*

*Strict Standards*: is_a(): Deprecated. Please use the instanceof operator
in */usr/share/php/PEAR.php* on line *281*

*Strict Standards*: Non-static method PEAR::isError() should not be called
statically, assuming $this from incompatible context in *
/usr/share/php/Mail/mail.php* on line *115*

*Strict Standards*: is_a(): Deprecated. Please use the instanceof operator
in */usr/share/php/PEAR.php* on line *281*

*Strict Standards*: Non-static method Mail::factory() should not be called
statically in */home/magsbyme/www/
ljhooker.ddm.magsbyme.com/lib/myTools.class.php* on line *1035*

*Strict Standards*: Non-static method PEAR::isError() should not be called
statically, assuming $this from incompatible context in *
/usr/share/php/Mail.php* on line *156*

*Strict Standards*: is_a(): Deprecated. Please use the instanceof operator
in */usr/share/php/PEAR.php* on line *281*

*Strict Standards*: Non-static method PEAR::isError() should not be called
statically, assuming $this from incompatible context in *
/usr/share/php/Mail/mail.php* on line *115*

*Strict Standards*: is_a(): Deprecated. Please use the instanceof operator
in */usr/share/php/PEAR.php* on line *281*

*Strict Standards*: Non-static method Mail::factory() should not be called
statically in */home/magsbyme/www/
ljhooker.ddm.magsbyme.com/lib/myTools.class.php* on line *1035*

*Strict Standards*: Non-static method PEAR::isError() should not be called
statically, assuming $this from incompatible context in *
/usr/share/php/Mail.php* on line *156*

*Strict Standards*: is_a(): Deprecated. Please use the instanceof operator
in */usr/share/php/PEAR.php* on line *281*

*Strict Standards*: Non-static method PEAR::isError() should not be called
statically, assuming $this from incompatible context in *
/usr/share/php/Mail/mail.php* on line *115*

*Strict Standards*: is_a(): Deprecated. Please use the instanceof operator
in */usr/share/php/PEAR.php* on line *281*

*Strict Standards*: Non-static method PEAR::raiseError() should not be
called statically, assuming $this from incompatible context in *
/usr/share/php/Mail/mail.php* on line *136*

*Strict Standards*: Non-static method PEAR::getStaticProperty() should not
be called statically, assuming $this from incompatible context in *
/usr/share/php/PEAR.php* on line *867*

*Strict Standards*: Non-static method Mail::factory() should not be called
statically in */home/magsbyme/www/
ljhooker.ddm.magsbyme.co

Re: [PHP] PHP Linux/Windows Outlook 2003 HTML email problem

2009-02-02 Thread German Geek
It seems like this solves the issue:
http://pear.php.net/bugs/bug.php?id=12032 Sorry, just hadn't found this
before.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Mon, Feb 2, 2009 at 7:24 PM, Chris  wrote:

> German Geek wrote:
>
>> Hi All,
>>
>> We've got a problem with our Ubuntu Linux machine sending HTML emails to
>> Outlook 2003:
>>
>> It's an Ubuntu Server (uname -a
>> Linux CDR2-221 2.6.24-19-server #1 SMP Wed Jun 18 15:18:00 UTC 2008 i686
>> GNU/Linux)
>>
>> with the newest version of Postfix installed as the Mail server.
>>
>> Unfortunately, all emails sent as HTML, using the PEAR library for sending
>> email like so:
>>
>
> Best place to look at this would be the pear list:
>
> http://pear.php.net/support/lists.php
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


Re: [PHP] Sometime the code works and sometimes doesn't

2009-02-05 Thread German Geek
I would also suggest that you hash the passwords at least (better even with
a salt value) and then reset the password to something random before sending
it to the user. Email can be sniffed relatively easily and this would expose
a possible carefully chosen password by the user and then they have to think
of something new which they probably forget (although, they probably forgot
the password in the first case :-).

Maybe there is a possibility that you have 2 or more user records with the
same email address? because then the result count would not be 1.

Cheers,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Sat, Jan 17, 2009 at 5:21 AM, Chris Carter wrote:

>
> Hi,
>
> Here is a code for PHP password sending. There is some strange thing
> happening. This code DOES WORK but not always. So I might be able to get
> the
> password in my mailbox once but not always. What could be wrong.
>
>// database information
>   $host = 'xxx';
>   $user = 'xxx';
>   $password = 'xxx';
>   $dbName = 'xxx';
>
>   // connect and select the database
>$conn = mysql_connect($host, $user, $password) or
> die(mysql_error());
>$db = mysql_select_db($dbName, $conn) or die(mysql_error());
>
> // value sent from form
> $emailAddress=$_POST['emailAddress'];
>
> $sql="SELECT password FROM mytable WHERE emailAddress='$emailAddress'";
> $result=mysql_query($sql);
>
> // keep value in variable name "$count"
> $count=mysql_num_rows($result);
>
> // compare if $count =1 row
> if($count==1){
>
> $rows=mysql_fetch_array($result);
>
> // keep password in $your_password
> $your_password=$rows['password'];
>
> $subject="Your password is retrieved";
>
> $header="from: Great Site";
>
> $messages= "Hi \n\n Your password for login to our website is
> retrieved.\n\n";
> $messages.="Your password is '$your_password' \n\n";
> $messages.="You can use this password";
>
> // send email
> $sentmail = mail($emailAddress, $subject, $messages, $header);
> }
> // else if $count not equal 1
> else {
> echo "Not found your email in our database";
> }
>
> // if your email succesfully sent
> if($sentmail){
> echo "Your Password Has Been Sent To Your Email Address.";
> }
> else {
> echo "Cannot send password to your e-mail address";
> }
>  ?>
>
> There must be something that I am doing wrong. Otherwise I could have
> always
> gotten the password in my mailbox. Please help.
>
> Thanks in advance,
>
> Chris
> --
> View this message in context:
> http://www.nabble.com/Sometime-the-code-works-and-sometimes-doesn%27t-tp21502951p21502951.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] function_exists question

2009-02-05 Thread German Geek
Why can't you update to Version 5? I might be a bit anal about trying to
always get the newest version of everything, but seriously version 3 has
surely more known security issues as well as performance costs.

What's the cost of upgrading compared to the cost of writing code that works
in every version? I think upgrading the system to PHP 5 will take you maybe
half an hour, while you can spend a lot more hours on writing backward
compatible code. PHP is not very good with compatibility across versions
anyway. Hopefully all PHP 5 code will work in PHP 6.

How about this PHP developers: You could make a global variable (or
constant) the user can set like

define('PHP_COMPATIBLE_VERSION', '5.0.1');

or something to tell PHP 6 to interpret it like PHP 5.x . That way, at least
you are guaranteed that the code will work like on that version. It might
make PHP 6 (a lot?) bigger but it might be worth the cost, since all Sites
written in PHP will still work. The functions could still have a performance
boost that way if there are better algorithms.

Sorry for steeling the thread.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Feb 6, 2009 at 12:55 AM, Thodoris  wrote:

>
>  Is there a way to check not only if a function exists, but also to check
>> that the number and types of parameters desired match a function definition?
>>
>> The reason being that additional options have been added in php 4 and 5 to
>> various standard function calls, but I'm still running a php3 and php4
>> server in addition to a php5 server.  I would like to make sure that certain
>> "extended" function calls still work in all versions (or I'll perform the
>> tasks "manually", albeit less efficiently).
>>
>> One example I can think of is the round() function.  The $precision
>> parameter was added in php4, so will not work in php3.  However,
>> function_exists would return TRUE for both 3 and 4, but round itself would
>> fail if I tried to send a precision level to the php3 server.
>>
>> Thanks much,
>> Matt
>>
>> P.S. Of course the modified "function_exists" would unfortunately have to
>> be a recognized function/method in php3 in order for me to call it to check
>> parameter counts on a php3 server :(
>>
>>
> I am sure you have some good reasons for keeping php3 right?
>
> Why don't you consider updating to at least php4 ??
>
> PHPv3 is not even maintained and PHPv4 is not being developed any more.
>
> So by the end of this year (I hope) we will start using a stable PHPv6.
>
> IMHO you should consider changing your code (if this is possible) to a more
> mainstream version.
>
> --
> Thodoris
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] German characters Ö,Ä etc. show up as ?

2009-02-05 Thread German Geek
Do they show up as ? just in the web page or in the source returned? Did you
check the source of the page? I had this problem before and as far as i
remember, i just needed to encode them like oe (have an american keyboard
;-) ö etc. If it's a literal ? in the source, it's PHP and you might
need to set your php.ini in some way to support your character set. Have a
look into Unicode as well. I haven't had this problem for a while since i
don't live in Germany anymore, but i'm sure i will probably come across this
some day ;-).

Good luck!

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Feb 6, 2009 at 1:37 AM, Merlin Morgenstern wrote:

> Hi there,
>
> I recently upgraded on my prod system from php 4.x to the newest php
> version. Now german characters lik "Ö" show up as ?. I have the same setup
> running on a test server, where the characters show up OK. After searching
> on Google I found that there is an entry in the php.ini:
> default_charset = "iso-8859-1" which could help me, however this is not set
> in the test environment! How come? Is there another way to fix this?
>
> Kind regards,Merlin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] How can I use a function's default arguments but change one of the end ones in the list?

2009-02-05 Thread German Geek
I've thought about this problem before but couldn't think of a solution
either. How does func_get_args() solve this? You could make a wrapper
function without that.

How would u (php) know which parameter u mean in a particular case?

I think it would just be useful to have an IDE that can write out the
default parameters on a keyboard shortcut or mouse click and then u can
change them afterwards.

Cheers,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Feb 6, 2009 at 1:56 PM, Daniel Brown  wrote:

> On Thu, Feb 5, 2009 at 18:50, Daevid Vincent  wrote:
> > Is there a way to use the default values of a function without
> > specifying every single one until the parameter you want to modify in
> > PHP5 ?
>
> Daevid,
>
>Check out func_get_args(): http://php.net/func_get_args
>
>Then you can rename your sql_query() function to real_sql_query()
> and create a new sql_query() as a wrapper function with
> func_get_args() in place of statically-defined variables.
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find
> out!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Question about version control.. sorta..

2009-02-05 Thread German Geek
I use GIT and Subversion. Subversion is still a bit hard to use (branching
etc) and not distributed but that was before i knew about GIT :-P. You have
a central repository that you need to commit to and it's still quite CVS
like (which is really confusing and horrible).

GIT is nice and fast and also works in a distributed environment. So, it's
great when you are the only one working on it or even if you have developers
that don't always have broadband and want to commit to the central
repository (when they are connected). It also has a windows port that is
reasonably easy to install. Check out the cygwin unix on windows port
library. It's great when you want the best of both worlds. Git is a package
that you can select in there. I use windows at work and cygwin for all the
unix stuff i want to do in windows, like perl, bash etc. It's awesome!

Spending $150 on this is not really worth it i think and using a database
for version control seems a bit odd. They have a database internally anyway
which is optimised for the purpose and stored as files. Databases store the
data as files (on disk) as well and only have the benefit that some of the
data is stored partially in memory (indeces etc) and speeds up data
retrieval (and i believe writing it too)...

So give GIT a go. It also has a windows shell extension called 'Git
Extensions'.

Although you might like the GUI stuff, i think it's a lot easier to fire up
a console (cmd or bash) and write

git init
git add .
git commit -a -m "your msg"

>From then on, you just have to type:
git commit -a -m "your msg"
to make commits. There is lots of help for it on the web which you wont get
with a proprietary solution. In general Open Source seems to have better
support than closed source (simply because there are a lot more people who
are willing to help because they want to and not because they get paid).

You can create a central repository relatively easy too and push/pull your
commits to your local repository (
http://toolmantim.com/articles/setting_up_a_new_remote_git_repository ). You
can also use one of the many repositories out there if you don't want to
take care of backups etc.

BTW, what do you need incremental backups for in a versioning system? A
versioning system is an incremental backup (an advanced one)! You might want
to backup the whole repository to a different location but you can safely
overwrite that.

I think Linus Torwalds did a really good job on that :-). Hail Linus (lol).
It's versioning as easy as it can get.

Hope this helps someone.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Feb 6, 2009 at 3:06 PM, TG  wrote:

> So, for my purposes.. after trying a handful of solutions.. open source and
> commercial..  I think I've decided that Reliable Software's "Code Co-op"
> is what's going to work best for me.
>
> My trial is almost up, so as soon as my next paycheck comes, I think I'll
> be purchasing the full version for $150.
>
> For me, it's totally worth it.   It stores everything in a local database,
> but allows collaboration if that's what you're into.  Via email for the
> $150 version, via LAN for the $200 version.
>
> It lets me add files by type, is easy to check out files.  Anyway.. if
> anyone's looking for an easy Windows version control system, check it out.
>
> (no, I don't work for them, just passing along the recommendation since I'm
> digging this software)
>
> Thanks for all the input!
>
> -TG
>
> - Original Message -
> From: "TG" 
> To: php-general@lists.php.net
> Date: Wed, 31 Dec 2008 11:40:23 -0500
> Subject: [PHP] Question about version control.. sorta..
>
> > Ok.. so I know about CVS and SVN and unfortunately haven't had as much
> > experience with them as I'd like.  I've used them, but always in a really
> > basic sense and always on systems that have already been set up.  A
> friend
> > recently mentioned GIT ( http://git.or.cz/ ) too.
> >
> > But here's my situation..  I deal with dozens of clients.  I usually make
> a
> > backup copy of their site (at least the files, not usually the DB) so I
> > have the latest copy of the site to make changes to.  Usually I'm the
> only
> > one working on the site, but sometimes other people may make changes too.
>
> > Not so often than we're conflicting with our changes, or if this is a
> known
> > issue, we make sure to coordinate.
> >
> > What I'd ideally like to do is be able to use a CVS type system to keep
> > incremental backups of the code.  So instead of checking code out of CVS,
> > changing it, then checking it back in... I'd like to just do a mass
> checkin
> > of the whole site and have changes recorded and the ability to look at
> > previous versions with DIFF and all that.  And of course the ability to
> > 'check out' a previous set of files by date or revision maybe.
> >
> >
> > I assume you can do this with one of the major version control systems,
> but
> > mostly what I see with how to use these systems involves checking code
> out
> > t

Re: [PHP] Session variables

2009-02-06 Thread German Geek
The session data is stored on the server. In the user's browser, only a
session cookie is stored, usually a random session id string. I could never
retrieve the session variables with any browser tools, always only with PHP
by echoing them out or something. Also, a cookie is simply a text file with
a maximum of 4096 characters on the user's browser, not enough to store big
session variables with big objects. So, the user's browser just stores a
cookie with the session id, so that the server knows which user to map to
which session variables. The session variables (in PHP) are stored in the
temporary directory on the server in a text file (flattened or serialized),
where the server can retrieve them across requests. This is important for
security reasons. You might not want the user to be able to view certain
variables in their browser otherwise they could change them and cause some
damage, e.g. imagine a user has a permission level between 1 and 10 and 1 is
the super user. You can store this level in a session variable, and the user
cannot change it. If they could, it would be a disaster! Also, if one could
store more than 4096 characters, it would be relatively easy to write out
some session variables in order to flood the browser memory and make it
crash or even worse.

Oh, and the Cookies, as far as i know, are always sent in the http headers.
They are stored on both client and server and can be set on both sides, with
javascript or server side code (php). So they can only be checked in every
request by the server side code, and while javascript is being executed on
the client.

Please correct me if I'm wrong because I would need to review a lot of code
in which it is assumed that session variables are NOT stored on the user's
machine.


Makes sense?

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Sat, Feb 7, 2009 at 8:11 PM, Phpster  wrote:

> A Session is stored on the user browser in a session ( in memory cookie)
> and on the server as a file. The session mgmt tools will read the file as
> needed.
>
> Bastien
>
> Sent from my iPod
>
>
> On Feb 7, 2009, at 1:58, Paul M Foster  wrote:
>
>  I'm not too clear on HTTP headers, cookies, and such. So here are
>> questions related to that. Let's say I generate a random number that I
>> want the user to enter in a form. When I generate the number, I store it
>> in a session variable ($_SESSION). When the user submits the form, I
>> check the number they enter with what I've stored in the session
>> variable.
>>
>> Since this session variable survives across page loads (assuming
>> session_start() is appropriately called), how is it stored and recalled?
>>
>> Is it automatically stored as a cookie on the user's system?
>>
>> Or is it stored on the server?
>>
>> And how does a server "get" a cookie?
>>
>> Is it a separate request made by the server to the client?
>>
>> If the value I've asked the user for is *not* stored as a cookie, then
>> is it passed as part of the HTTP submission or what?
>>
>> Thanks for any enlightenment on this.
>>
>> Paul
>> --
>> Paul M. Foster
>>
>> --
>> 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] Session variables

2009-02-07 Thread German Geek
Yeah i guess the cookie doesn't need to be stored on the server since it's
in the header anyway.

Thanks for clearing that up.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles M. Schulz  - "I love mankind; it's people I can't stand."

2009/2/7 Stuart 

> 2009/2/7 Paul M Foster :
> > I'm not too clear on HTTP headers, cookies, and such. So here are
> > questions related to that. Let's say I generate a random number that I
> > want the user to enter in a form. When I generate the number, I store it
> > in a session variable ($_SESSION). When the user submits the form, I
> > check the number they enter with what I've stored in the session
> > variable.
> >
> > Since this session variable survives across page loads (assuming
> > session_start() is appropriately called), how is it stored and recalled?
> >
> > Is it automatically stored as a cookie on the user's system?
> >
> > Or is it stored on the server?
> >
> > And how does a server "get" a cookie?
> >
> > Is it a separate request made by the server to the client?
> >
> > If the value I've asked the user for is *not* stored as a cookie, then
> > is it passed as part of the HTTP submission or what?
> >
> > Thanks for any enlightenment on this.
>
> Session data is stored on the server and tied to a browser using a
> cookie. The cookie contains a random string which uniquely identifies
> a session on the server. The session_start() function handles all the
> details of setting and maintaining that cookie and managing the
> server-side data.
>
> Cookies are transferred between client and server with every request
> in the headers. If you don't have Firefox getfirefox.com. The google
> for the livehttpheaders addon and install that. Turn it on and browse
> your site. You will see the cookies in the headers of both requests
> and responses. Cookies are not stored on the server side, they are
> sent by the client with each request.
>
> No additional HTTP requests are involved when using sessions.
>
> -Stuart
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Re: move_uploaded_file() problem

2009-02-07 Thread German Geek
make sure the permissions on the folders are right, so at least read for the
httpd in the tmp folder and write in the destination folder. since its
moving i would make them both writeable to the webserver daemon user.
permissions can be annoying are necessary though...
They caught me quite a few times now, so its one of the first things i would
check.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles M. Schulz  - "I love mankind; it's people I can't stand."

2009/2/8 Alpár Török 

> 2009/2/7 Dušan Novaković 
>
> > On Sat, Feb 7, 2009 at 12:29 PM, Alpár Török 
> wrote:
> > >
> > >
> > > 2009/2/7 Dušan Novaković 
> > >>
> > >> Hi,
> > >>
> > >> I'm having problem with function move_uploaded_file() under Linux
> > >> (Slackware 12.2). It  simply won't execute only that function in php
> > >> file. So maybe I should add something to http.config file or  ? I
> > >> tried to execute that php file under Windows and it's working just
> > >> fine (I've copied whole project to xampp's htdocs folder and run it
> > >> normally).
> > >
> > > Can you show some code?
> >
> > This is part where I use function move_uploaded_file()
> >
> > if($_FILES['file']['name'] && $_FILES['file']['size']<55){
> >
> >$file_name =
> > "news_".$_FILES['file']['name'];
> >
> >  $image="../_img/news/".$file_name;
> >//Upload file
> >
> >  move_uploaded_file($_FILES['file']['tmp_name'], $image);
> >
> >
> > }
> >
> >
> > And normaly HTML code:
> >
> Make sure that the relative path resolves to what you think it does. Try to
> make a test with a hard coded absolute path, and do an echo
> realpath("../_img/news/$file_name"); to see the absolute path that it
> resolves to. It might be that the function does indeed work, but places
> files in annother folder than you expect it to.
>
> >
> >
> > 
> >  > enctype="multipart/form-data" name="form" id="form">
> >
> > ...
> >
> > 
> >  Slika [max 500kB; formati: gif, jpg, jpeg]:
> >
> >  
> > .
> >
> > >>
> > >>
> > >> And also I have question, does anyone knows how to configure apache
> > >> (also under same Linux) so that in future I woul
> > >>
> > >> dn't have to write
> > >>  > >
> > > You need to change the enable_short_tags  directive. It is probably
> more
> > > simple to do it in the php.ini configuration file and not in the apache
> > > configuration file, but you should know that short tags are off by
> > default
> > > because they conflict with xml.
> > >>
> > >> Thnx, Dusan
> > >>
> > >> On Sat, Feb 7, 2009 at 11:53 AM, Dušan Novaković 
> > wrote:
> > >> > Hi,
> > >> >
> > >> > I'm having problem with function move_uploaded_file() under Linux
> > >> > (Slackware 12.2). It  simply want execute only that function in php
> > >> > file. So maybe I should add something to http.config file or  ?
> I
> > >> > tried to execute that php file under Windows and it's working just
> > >> > fine (I've copied whole project to xampp's htdocs folder and run it
> > >> > normally).
> > >> >
> > >> > And also I have question, does anyone knows how to configure apache
> > >> > (also under same Linux) so that in future I wouldn't have to write
> > >> >  > >> >
> > >> > Thnx, Dusan
> > >> >
> > >> > --
> > >> > made by Dusan
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> made by Dusan
> > >>
> > >> --
> > >> PHP General Mailing List (http://www.php.net/)
> > >> To unsubscribe, visit: http://www.php.net/unsub.php
> > >>
> > >
> > >
> > >
> > > --
> > > Alpar Torok
> > >
> >
> >
> >
> > --
> > made by Dusan
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Alpar Torok
>


Re: [PHP] PHP OOP

2009-02-10 Thread German Geek
A loosely typed language like PHP might not be the best choice for teaching
OOP, because even though PHP makes it easier with loose types, you should
know about them and how they are stored etc.

PHP is a great language but maybe not strict enough for students to
understand all the errors that can occur. I would recommend encouraging
learning PHP though as it has become both an important and fast and easy
language to program in. For that it's also amazingly fast in execution.

Cheers,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Garry Shandling  - "I'm dating a woman now who, evidently, is unaware of
it."

2009/2/11 tedd 

> At 9:36 AM -0500 2/10/09, Andrew Ballard wrote:
>
>> On Tue, Feb 10, 2009 at 8:40 AM, Carlos Medina 
>> wrote:
>>  > Marcus Gnaß schrieb:
>>
>>  > Hi @ all,
>>
>>>  but this is a php list...
>>>
>>>  Regards
>>>
>>>  Carlos
>>>
>>>
>> Yes, it is, but the original question was about OOP and not
>> specifically about PHP. It seems fair enough to me for someone to ask
>> the question on this list since PHP was one of the languages being
>> considered, even if consensus among the list seems to be that PHP
>> would not be the best choice for teaching a course on OOP.
>>
>> Andrew
>>
>
>
> Andrew:
>
> Absolutely, you're not out of line at all.
>
> TI have found in my life that there will always be those who have a better
> idea, if you know what I mean.
>
> The point of the post (me being the OP) was to sample other people's
> opinion as to what would be best language to use to teach OOP, and that
> included considering php, thus the relevancy.
>
> The answer turns out to be Java (1) or C++ (2) depending upon the
> environment and availability of resources.
>
> Why people have to get on and comment that this is a php list is beyond me,
> duh.
>
> Cheers,
>
> tedd
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] (Perl) Regular Expressions - oposite match or get the non-matches of a substring

2009-02-10 Thread German Geek
Hi all,

I consider myself quite good with Regular Expression, but i could never find
out how to match something like:

"match this but not this and that"

so i would like to match the first "match this" (or "another this") but not
"not this".

Seems pretty straight forward but i haven't found a (good) solution yet.
Please no solutions with extra code, i know how to do that. I need a regular
expression that can do it, preferably Perl compatible. Surprisingly i
couldn't figure out how to say '/!(not) this/'. Seems like there must be a
simple way, but i can't seem to figure it out.

Tried things like: '/[^n][^o][^t] this/', '/[^not]{3} this/' etc but all of
those don't work. Looked in various books and websites but didn't find what
i was looking for...

Please enlighten me if you can.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Bob Hope  - "I have a wonderful make-up crew. They're the same people
restoring the Statue of Liberty."


Re: [PHP] Re: Looking for some PHP OO programming guides

2009-02-10 Thread German Geek
I try to avoid nesting loops altogether if possible. Usually dont go beyond
3 levels of nesting...
How can you require 8 levels of nesting? surely there must be something
wrong or a more efficient algorithm...

Tim-Hinnerk Heuer

http://www.ihostnz.com
Garry Shandling  - "I'm dating a woman now who, evidently, is unaware of
it."

2009/2/11 Andrew Ballard 

> On Tue, Feb 10, 2009 at 3:09 PM, Kyle Terry  wrote:
> > On Tue, Feb 10, 2009 at 12:07 PM, Kyle Terry  wrote:
> >> On Tue, Feb 10, 2009 at 9:46 AM, Tony Marston
> >>  wrote:
> >>> Take a look at
> http://www.tonymarston.net/php-mysql/databaseobjects.html
> >>>
> >>> --
> >>> Tony Marston
> >>> http://www.tonymarston.net
> >>> http://www.radicore.org
> >>>
> >>> "Michael Kubler"  wrote in message
> >>> news:49918ebf.4070...@gmail.com...
>  Hi,
>  I'm just getting into programming in an Object Oriented fashion, and
> am
>  looking for some guides, tutorials, hints, tips, etc...
> 
>  I only just found out that you remove the $ from variables when
> calling
>  them from $this->
> 
>  e.g :
>    class People
>  {
>  private $person = "not set";
> function __construct()
> {
>  *$person* = "A person"; //This doesn't work (well it creates a
>  variable $person that only has the scope of the current function from
>  what I can gather)..
>  $this->*person* = "A person"; //This works properly
>  }
> function display_list()
> {
> echo $person; //This doesn't work
>   echo $this->person; //This works.
> }
>  }
> 
>  $person= new People;
>  $person->display_list();
>  ?>
> 
> 
>  Instead of painstakingly working out most of the other mistakes I'm
>  likely to make, I'd love to read about other peoples issues they had
>  with learning OO so I can skip most of the hard stuff, and only make
>  small mistakes (hopefully).
>  --
> 
>  Michael Kubler
>  *G*rey *P*hoenix *P*roductions 
> 
> 
> >>>
> >>>
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >>
> >> Don't next 8 foreach loops in OOP.
> >>
> >> --
> >> Kyle Terry | www.kyleterry.com
> >> Help kick start VOOM (Very Open Object Model) for a library of PHP
> classes.
> >> http://www.voom.me | IRC EFNet #voom
> >>
> >
> > Don't neSt 8 foreach loops in OOP.
>
> Yikes! I'd try my best to avoid nesting 8 foreach loops in procedural code,
> too.
>
> > --
> > Kyle Terry | www.kyleterry.com
> > Help kick start VOOM (Very Open Object Model) for a library of PHP
> classes.
> > http://www.voom.me | IRC EFNet #voom
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Simple open source CMS as a starting point

2009-02-12 Thread German Geek
Drupal is probably not the easiest at first, but has a good API and buckets
full of modules, themes and all that stuff. If a framework would be what you
are looking for, i would recommend Symfony. Also heard good things about eZ
Publish, Textpattern, Typo3, Website Baker and WordPress. You can find an
extensive list at

http://php.opensourcecms.com/scripts/show.php?catid=all&cat=All%20Scripts .

Good luck finding the right one for you. I know quite a bit about Symfony,
Joomla/Virtuemart and Drupal but nothing about the others. If you want
support with the ones i know, i might be able to help...

regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Marlene Dietrich  - "Most women set out to try to change a man, and when
they have changed him they do not like h...

2009/2/12 Jean Pimentel 

> Wordpress
>
> Att,
> Jean Pimentel
> Museu da Infância - www.museudainfancia.com
>
> On Thu, Feb 12, 2009 at 7:01 AM, Lester Caine  wrote:
>
> > dzenan.cause...@wise-t.com wrote:
> >
> >> I need simple CMS sistem that I could use as a staring point (to save
> some
> >> time in setting up the structure) in developing my own CMS. The code
> >> should be simple to understand so that I can easily get on and start
> >> building on it. It would be of great help if it already had features
> like
> >> statistics, rss feeds, and multi-language support (visitors can click on
> >> the flag at the top of the page and have the pages display the content
> in
> >> that particular language), but if it doesn't it's okay I would build
> them.
> >>
> >> For example Joomla seems to be too powerfull, and pretty diffucult to
> >> understand at the coding level in order to customize it to serve my
> >> specific needs.
> >>
> >> Does anyone know of any promising open source CMS project that I could
> use
> >> in this respect?
> >>
> >
> > bitweaver ...
> > http://bitweaver.org
> > Just select the packages you want when you install, and add other
> > facilities latter as you need them ...
> >
> > --
> > Lester Caine - G8HFL
> > -
> > Contact - http://lsces.co.uk/lsces/wiki/?page=contact
> > L.S.Caine Electronic Services - http://lsces.co.uk
> > EnquirySolve - http://enquirysolve.com/
> > Model Engineers Digital Workshop - http://medw.co.uk//
> > Firebird - http://www.firebirdsql.org/index.php
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>


Re: [PHP] Happy 1234567890 day!

2009-02-13 Thread German Geek
It's not the 1234567890th day! Its the 12345Gmail - [PHP] Happy 1234567890
day! - th.he...@gmail.com 67890 second
since beginning of 1970:

2009-02-14 12:31:30

is the result of

$a = 1234567890;// * 60*60*24;
die(date("Y-m-d H:i:s", $a));

Anyway happy 1234567890 second to all of you, although i'm sure i'm late lol
(i'm a German who is always late).

Regards,

Tim-Hinnerk Heuer

http://www.ihostnz.com
Mike Ditka  - "If God had wanted man to play soccer, he wouldn't have given
us arms."

2009/2/14 alexus 

> wot!!!
>
> On Fri, Feb 13, 2009 at 6:38 PM, Eric Butera 
> wrote:
> > On Fri, Feb 13, 2009 at 5:13 PM, Gary Maddock-Greene
> >  wrote:
> >> Note quite there yet here but yes Happy 1234567890 day to you too
> >>
> >> --
> >> - Gary Maddock-Greene
> >> "Luke Slater"  wrote in message
> >> news:200902131812.43295.l...@blog-thing.com...
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > woot!
> >
> > --
> > http://www.voom.me | EFnet: #voom
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>
> --
> http://alexus.org/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] for the security minded web developer - secure way to login?

2009-02-14 Thread German Geek
Hi All,

A few months ago it came to my mind, that it might be possible to make
non-https session (reasonably) secure by at least not letting people login
that shouldn't because they might have sniffed the password from a user.
Please let me know if you can find a loop hole in this process. I think it
would be interesting for anybody on this list (or anybody really) who has a
bit of knowlege and appreciation about security:

Assumptions:

The session variables are stored on the web server and not transferred to
the client at all.
The client has Javascript enabled.
We have a secure hash function, say sha1.
We can generate truly random numbers/strings with PHP which cannot be
guessed call it salt.
A session cannot be stolen.
... add more if needed. :-)

So, we could on the server generate a random salt value and send that to the
client along with the login form.
On the client, when the user submits the form, we take the entered password
value (with Javascript), hash it with our sha1 function, concatenate it with
the salt and compute the hash value of the password together with the salt
(again). All this in Javascript or whatever runs on the client.

We then send this hash value, call it h(h(p) + s) (hash(hash(password) +
salt)), to the server. Its useless for the sniffer, because the same value
will never be sent twice, unless of course the user (password) and the salt
are the same (or there is a collision, but we assumed its a secure hash
function).
We could make sure that a user doesn't get sent the same salt twice by
storing them in the database when used and checking against them when it is
generated.
On the server we could do the same process with the stored hash of the
password (assuming the hash of the password is stored), otherwise it becomes
necessary to also send the actual salt of the password along with the login
form and this would become even a little more complex.

So, if h(p) is stored, we would simply compute h(h(p) + s) where s is the
salt that was sent and stored in a session variable.

Assuming we don't use a salt to store the password hash, this seems quite
secure to me, don't you think? I mean, of course someone can still steel the
session but it becomes a lot harder to figure out the password by sniffing.

What do you think?

If everybody agrees this is worth implementing, i might give it a go and
make a library.

Sorry this is not directly PHP related, but since i like this list, i
thought i would share it with you.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Joan Rivers  - "Never floss with a stranger."


Re: [PHP] [Fwd] How to make a secured login form

2009-02-14 Thread German Geek
Have a look at my post called "for the security minded web developer -
secure way to login?". It seems like a similar idea with less overhead.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Joan Rivers  - "Never floss with a stranger."

2009/2/14 Virgilio Quilario 

> > I have secured the login form for my CMS with a challenge-response thing
> > that encrypts both username and password with the
> > (login-attempts-counted) challenge (and; here's my problem: a system
> > hash) sent by the server (it would end up in your html as a hidden
> > inputs, or as part of a json transmission)..
> >
> > Since then, i've found these libs that do even longer one-way-crypto:
> > http://mediabeez.ws/downloads/sha256.js-php.zip
> > The principles i'm about to explain stay the same.
> >
> > *but i'd really like to know if my crypto can be improved*
> >
> > So instead of the browser getting just a text-field for username and
> > password, you also send the "challenge" (and "system_hash") value.
> > That's a 100-character random string (include special characters!), then
> > sha256-ed (for prettiness mostly i think).
> >
> > I really wonder if i can do without the systemhash..
> >
> >  HTML
> 
> > 
> >> value="[SHA256 SORTA-MASTER-KEY__DUNNO-WHAT-TO-DO-WITH-THIS]"/>
> >> value="[SHA256RANDOMSTRINGFROMPHP]"/>
> >   
> >   Login  > name='login'/>
> >   Password  > name='pass'/>
> >   
> > 
> >
> >
> >  JS
> 
> >
> >   $('#myform').submit (function() {
> >   var s = ($'system_hash')[0];
> >   var c = ($'challenge')[0];
> >   var l = $('#login')[0];
> >   var p = $('#pass')[0];
> >
> >   l.value = sha256 (sha256 (l.value + s.value) + c.value);
> >   p.value = sha256 (sha256 (p.value + s.value) + c.value);
> >
> >   //Here, submit the form using ajax routines in plain text,
> > as both the login name and
> >   //password are now one-way-encrypted.
> >   //
> >   //on the PHP end, authentication is done against a mysql
> > table "users".
> >   //
> >   //in this table i have 3 relevant fields:
> >   //user_login_name (for administrative and display purposes)
> >   //user_login_name_hash (==sha256 (user_login_name +
> > system_hash))
> >   //user_password_hash (== passwords aint stored unencrypted
> > in my cms, to prevent admin corruption and pw-theft by third parties;
> > the password is encrypted by the browser in the "new-password-form" with
> > the system hash before it's ever sent to the server. server Never knows
> > about the cleartext password, ever.)
> >   //
> >   //when a login-attempt is evaluated, all the records in
> > "users" table have to be traversed (which i admit can get slow on larger
> > userbases... help!?! :)
> >   //for each user in the users table, the loginhash and
> > password hash are calculated;
> >   //$uh = sha256 ($users->rec["user_login_name_hash"] .
> > $challenge);
> >   //$pwh = sha256 ($users->rec["user_password_hash"] .
> > $challenge);
> >   //and then,
> >   //if they match the hash strings that were sent (both of
> > them),
> >   //if the number of login-attempts isn't exceeded,
> >   //if the IP is still the same (as the one who first
> > requested the html login form with new challenge value)
> >   //then, maybe, i'll let 'm log in :)
> >   });
> >
> >
> >
> >
> > phicarre wrote:
> >>
> >> How to secure this jquery+php+ajax login procedure ?
> >>
> >> $('#myform').submit( function()
> >>{
> >>$(this).ajaxSubmit( {
> >>type:'POST', url:'login.php',
> >>success: function(msg)
> >>{
> >> login ok : how to call the welcome.php ***
> >>},
> >>error: function(request,iderror)
> >>{
> >>alert(iderror + " " + request);
> >>}
> >>});
> >>return false;
> >>})
> >>
> >>
> >> 
> >>
> >>Name : 
> >>Password :  >>
> >>>
> >>> 
> >>>
> >>
> >>
> >>
> >> 
> >>
> >> Login.php check the parameters and reply by echo "ok" or echo "ko"
> >>
> >> Logically if the answer is ok we must call a welcome.php module BUT,
> >> if someone read the client code, he will see the name of the module
> >> and can hack the server.
> >> May I wrong ? how to secure this code ?
> >>
>
> i think you should drop the IP address out of the equation because
> when you're behind a firewall with rotating outgoing IP addresses, you
> will never get authenticated.
>
> also, traversing users table is a slow operation as you pointed out.
>
> i guess you should look into two way encryption or use ssl which is
> better and easier to implement.

Re: [PHP] Execute EXE with variables

2009-02-14 Thread German Geek
Hi,

I've had a lot of problems with shell_exec too. Mostly it was permissions or
environment variables not being set. i dont know if there is a way to set
environment variables in the php.ini but if not you can set them with
shell_exec as well, at least on unix it works. You can simply concatenate
the commands necessary with a colon (;) inbetween. Maybe you can have
multiple shell_exec commands and it stays in the same env. Not sure about
this though. Please someone enlighten us on this...

Hope some of this helped.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Jay London  - "My father would take me to the playground, and put me on mood
swings."

2009/2/14 Dan Shirah 

> >
> >  Use the system() command, and enclose both your command and its
> > parameters in a pair of single quotes, as:
> >
> > system('mycmd -a alfa -b bravo');
> >
> > Paul
> > --
> > Paul M. Foster
> >
>
> Using both exec() and system() I am getting the error: Unable to fork
>


Re: [PHP] list all constitute group of array ?

2009-02-14 Thread German Geek
Do you want exactly that list or simply all the possible combinations?

If you want all possible combinations, search for a permute or permutation
function in php...

Does sound like homework lol. :-)

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Alanis Morissette  - "We'll love you just the way you are if you're
perfect."

2009/2/14 LKSunny 

>  $a = array("a", "b", "c", "d");
>
> /*
> how to list:
> abcd
> abc
> ab
> ac
> ad
> bcd
> bc
> bd
> cd
> a
> b
> c
> d
>
> who have idea ? thank you very much !!
> */
> ?>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] for the security minded web developer - secure way to login?

2009-02-14 Thread German Geek
Hi gang,

Was just thinking of a cheap solution for sites that don't require absolute
security. A SSL cert cost about $150 a year. Sites like facebook could use
this... Of course it's not for banks etc.

You could degrade gracefully when javascript is turned off to just sending
the form and checking the password normally if the first test fails which
would happen anyway wouldnt it? ...

Mainly this was just ment to be a proof of concept. An alternative to SSL
for those who have more time than $$ and not quite so high a security
requirement.

Of course SSL is better! Duh! Just wanted to give you guys something to
think about. The password would not be given away like this would it? It
just makes it a little more difficult for script kiddies. They would have to
have a keylogger running or steal the session. :P

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Mike Ditka  - "If God had wanted man to play soccer, he wouldn't have given
us arms."

2009/2/15 Michael A. Peters 

> Dotan Cohen wrote:
>
>
>> Have you seen the fit Firefox 3 makes for self-signed certs? So far as
>> the end user is concerned, the site is inaccesible.
>>
>>
> Yes I have.
> That's why on my site I have an instruction page - and a demonstration of
> how Opera does it, which is just as secure and less of a PITA, and a
> suggestion that users go ahead and try Opera - something I never did before
> FF messed up the self signed SSL process.
>
> The FF3 really bugged me -
>
> 1) The purpose of SSL is to provide public/private key encryption.
> 2) The purpose of signing is so that they know you are really you on future
> visits.
> 3) The purpose of certificate authorities is so that they know you are you
> on the first visit.
>
> Many web sites benefit from the first two without needing the complexity of
> the third, a concept FireFox seems to have lost.
>
> I don't need the paperwork hassle etc. for the few sites I run - I just
> need a way for a user to authenticate so I can give 'em a session cookie, no
> sensitive data is ever collected. Ah well.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] for the security minded web developer - secure way to login?

2009-02-15 Thread German Geek
OK, i hear about this self signed certificate. Whenever i signed anything it
just came up with all these warnings in FF which confuses users and i think
is not good at all. Can someone paste a link in here to a website with a
self signed cert please? Would like to see if there are any warnings etc.
Thanks.

Tim
Tim-Hinnerk Heuer

http://www.ihostnz.com
Jay London  - "My father would take me to the playground, and put me on mood
swings."

2009/2/15 Michael A. Peters 

> Sudheer wrote:
>
>> Michael A. Peters wrote:
>>
>>>
>>> Sites (like mine) that don't want to pay a certificate authority can use
>>> a self-signed cert. Even Red Hat does for some of their stuff (IE I believe
>>> their bugzilla server)
>>>
>>>  Firefox scares its users when they encounter a website with self signed
>> certificate. If your website users aren't worried about the warning Firefox
>> throws at them, self signed cert works well.
>>
>>
>>
> Yeah it does, hopefully they fix it.
> What scares me is allowing sites I have no reason to trust as non malicious
> and have no reason to trust as properly secured against XSS injection to
> load scripts that execute on my machine.
>
> People who use Firefox may be scared by the absurd warning FireFox 3 uses
> (something I've complained about to them) - other than informing users of
> the issue and hoping some read it, not much I can do about that. Hopefully
> FireFox will fix the issue and do something like what opera does (except the
> cert for session if you just click OK, accept it permanently if you click
> the security tab and check a box first).
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] for the security minded web developer - secure way to login?

2009-02-15 Thread German Geek
Hi All again,

What makes it so expensive to have a certificate? I mean, wouldn't it be
possible to setup a new authority that doesn't charge as much or nothing at
all? Wouldn't the major browsers be willing to support an authority that is
free or costs next to nothing? I pay about $200 a year for my virtual
server, so if i only issue 200 certifcates and charge a dollar each i
wouldn't loose money. I have a v-server on the Internet and wouldn't mind
setting it up as a free authority or even one based on donations. Or is
there going to be so much traffic and processing that it wouldn't be able to
handle it? Cannot be that bad because it needs to compute the authentication
only periodically (once a year or so for each) and each time a user hits a
page it is only checked which would only be a couple of bytes traffic (per
domain?).

Please enlighten me why it is so expensive? Is it maybe just the hassle of
setting it up?

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Fred Allen  - "California is a fine place to live - if you happen to be an
orange."

2009/2/16 Michael A. Peters 

> German Geek wrote:
>
>> OK, i hear about this self signed certificate. Whenever i signed anything
>> it
>> just came up with all these warnings in FF which confuses users and i
>> think
>> is not good at all. Can someone paste a link in here to a website with a
>> self signed cert please? Would like to see if there are any warnings etc.
>> Thanks.
>>
>
> There still are all the warnings.
>
> There are some cheap (and free) CA's that FireFox recognizes so it still is
> possible to use SSL and not have the firefox 3 warning hell, but things like
> linksys routers are still problematic.
>
> https://www.scientificlinux.org/
>
> Demonstrates the problem in FireFox 3.
> They use a self-signed cert.
>


Re: [PHP] Re: Sorting times

2009-02-15 Thread German Geek
The easiest would probably to use
http://nz.php.net/manual/en/function.strnatcmp.php . It would happen to sort
it the right way because am is before pm ;-).

You can of course make it more challenging by converting it into a timestamp
etc. That would be better if you want to sort by date as well etc. If you go
that way you should look at http://nz.php.net/manual/en/function.usort.php .

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Alanis Morissette  - "We'll love you just the way you are if you're
perfect."

2009/2/15 Shawn McKenzie 

> Shawn McKenzie wrote:
> > tedd wrote:
> >> Hi gang:
> >>
> >> Anyone have/know a routine that will sort an array of times?
> >>
> >> For example, a function that would take an array like this:
> >>
> >> time[0] ~ '1:30pm'
> >> time[1] ~ '7:30am'
> >> time[2] ~ '12:30pm'
> >>
> >> and order it to:
> >>
> >> time[0] ~ '7:30am'
> >> time[1] ~ '12:30pm'
> >> time[2] ~ '1:30pm'
> >>
> >>
> >> Cheers,
> >>
> >> tedd
> >>
> >>
> >
> > Not tested:
> >
> > function time_sort($a, $b)
> > {
> > if (strtotime($a) == strtotime($b)) {
> > return 0;
> > }
> > return (strtotime($a) < strtotime($b) ? -1 : 1;
> > }
> >
> > usort($time, "time_sort");
> >
> Well, I just thought, since the strtotime() uses the current timestamp
> to calculate the new timestamp, if you only give it a time then the
> returned timestamp is today's date with the new time you passed.  If you
> had a large array and the callback started at 23:59:59 then you could
> end up with some times from the date it started and some from the next
> day, which of course would not be sorted correctly with respect to times
> only.  So, this might be better (not tested):
>
>
> function time_sort($a, $b)
> {
> static $now = time();
>
>if (strtotime($a, $now) == strtotime($b, $now)) {
>return 0;
>}
>return (strtotime($a, $now) < strtotime($b, $now) ? -1 : 1;
> }
>
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Re: Sorting times

2009-02-15 Thread German Geek
Yes, you are right. Hadn't thought about that. But usort is probably better
than making your own sort function because it uses the quick sort algorithm
i believe which is quite efficient. That was the other suggestion...

Tim-Hinnerk Heuer

http://www.ihostnz.com
Fred Allen  - "California is a fine place to live - if you happen to be an
orange."

2009/2/16 Mattias Thorslund 

> German Geek wrote:
>
>> The easiest would probably to use
>> http://nz.php.net/manual/en/function.strnatcmp.php . It would happen to
>> sort
>> it the right way because am is before pm ;-).
>>
>>
>
>
> Nope. Unfortunately 12 am (midnight) comes before 1 am, and 12 pm (noon)
> comes before 1 pm. Since you have to account for that, you solution won't be
> as elegant.
>
> Cheers,
>
> Mattias
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Back to Basics - Re: [PHP] Re: for the security minded web developer - secure way to login?

2009-02-16 Thread German Geek
ey
> dont get transmitted (same for plain_pass ofcourse)
>
>jQuery.ajax ( /* submit login form through POST, handle results */ )
>  }
>
>
>  PHP, on receiving the login form data:
>
> // walk through all the records in users table, for each, calculate:
>user_hash = onewayHash ( users[user_id].user_login_hash + challenge
> );
>pass_hash = onewayHash ( users[user_id].user_password_hash +
> challenge );
>
> // if they match what was sent, then it's the user we're looking for
> with the right password, so their $_SESSION['authenticated_user'] = updated.
>
> 
>
>
> If you have a completely alternative way of securing a non-ssl login form,
> i'd like to hear about it too.
>
>
>
>
> Michael A. Peters wrote:
>
>> Colin Guthrie wrote:
>>
>>> 'Twas brillig, and German Geek at 15/02/09 22:32 did gyre and gimble:
>>>
>>>> Please enlighten me why it is so expensive? Is it maybe just the hassle
>>>> of
>>>> setting it up?
>>>>
>>>
>>> The whole thing is about trust. Getting a certificate is nothing if the
>>> system is not backed up by a trust system. If a CA was setup that gave out
>>> certificates willy nilly to all and sundry, then this element of trust is
>>> lost.
>>>
>>
>> Cheap CA's do exist. They have crappy web sites and send you all kinds of
>> junk mail etc. if you use them - but they do exist.
>>
>> I might end up just paying godaddy - I think they charge $12.00 / year,
>> but since I already register through them, they already have my address etc.
>>
>> But the problem I have with FF3 is that I shouldn't have to.
>> I don't need to prove to the user that I am really me, and I don't want to
>> use a cert that some other organization has control over and can choose to
>> revoke at any time. I just the flipping password encrypted by SSL so that
>> when Betty who uses the same password for everything (it's amazing how many
>> people do) logs onto my server while she has coffee at Starbucks, her
>> uname/password isn't sniffed giving Cracker Jack access to Betty's PayPal
>> account.
>>
>> If Cracker Jack wants to do a man in the middle attack - as long as Betty
>> has already connected to me before, her browser will still inform her that
>> the certificate doesn't match - whether or not I am self signed, so the man
>> in the middle attack is really not the big deal FireFox makes it out to be.
>>
>> What they should do is a simple notification telling the user they can't
>> verify the website is who it claims to be, and a link for more info if the
>> user wants more info.
>>
>> But alas, that has nothing to do with php, so I apologize to the list.
>>
>> Anyway, back on topic - if you want to encrypt login, use SSL.
>> You can self sign for free.
>> If you don't want the FireFox 3 issue, there are a few free and plenty of
>> cheap certificate authorties that FireFox recognizes.
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Re: Sorting times (SOLVED before tedds crappy SOLVED)

2009-02-16 Thread German Geek
Remember we have copy-on-write in PHP.

Beat this :P :


Tim-Hinnerk Heuer

http://www.ihostnz.com
Fred Allen  - "California is a fine place to live - if you happen to be an
orange."

2009/2/16 Jochem Maas 

> Shawn McKenzie schreef:
> > Shawn McKenzie wrote:
>
> ...
>
> >>> Not tested:
>
> no shit.
>
> >>> function time_sort($a, $b)
> >>> {
> >>> if (strtotime($a) == strtotime($b)) {
> >>> return 0;
> >>> }
> >>> return (strtotime($a) < strtotime($b) ? -1 : 1;
> >>> }
> >>>
> >>> usort($time, "time_sort");
> >>>
> >> Well, I just thought, since the strtotime() uses the current timestamp
> >> to calculate the new timestamp, if you only give it a time then the
> >> returned timestamp is today's date with the new time you passed.  If you
> >> had a large array and the callback started at 23:59:59 then you could
> >> end up with some times from the date it started and some from the next
> >> day, which of course would not be sorted correctly with respect to times
> >> only.  So, this might be better (not tested):
> >>
>
> ditto (as in nice syntax error).
>
> >>
> >> function time_sort($a, $b)
> >> {
> >> static $now = time();
> >>
> >> if (strtotime($a, $now) == strtotime($b, $now)) {
> >> return 0;
> >> }
> >> return (strtotime($a, $now) < strtotime($b, $now) ? -1 : 1;
> >> }
> >>
> >>
> > Your best bet above.
>
> and G.W.Bush is a socialist.
>
> >
>
> I did a little test, the ultra-fast version offered by McKenzie
> is really great as long as your array of time strings aren't ever
> going to be longer than say 3-4 items (with the caveat that you
> don't use a second argument to strtotime() ... if you do then
> even with 3 items it's substantially slower).
>
> for any reasonable number of items my tests show tedd's version
> pisses on McKenzies from a great height (note that I actually
> optimized Mckenzies variant by halfing the number of calls to
> strtotime()).
>
> I added a third variant, as a sort of control, which runs pretty
> much on par with tedd's version but uses rather less LOC
> (tedd you might like it as a little example of using array_multisort(),
> i.e. a way of avoiding writing the double foreach loop in this case)
>
> tedd's variant: sortTime1()
> McKenzie's variant: sortTime2()
> my variant: sortTime3()
>
> sample output from one of my test runs:
> ===
> ===
> No. of array items = 3, no of iterations = 1
> ---
> timeSort1() ran for 1.306011 seconds
> timeSort2() ran for 1.337358 seconds
> timeSort3() ran for 1.742724 seconds
>
> No. of array items = 6, no of iterations = 1
> ---
> timeSort1() ran for 2.647697 seconds
> timeSort2() ran for 2.475791 seconds
> timeSort3() ran for 7.268916 seconds
>
> No. of array items = 9, no of iterations = 1
> ---
> timeSort1() ran for 3.891894 seconds
> timeSort2() ran for 3.960463 seconds
> timeSort3() ran for 18.440713 seconds
>
>
>
>
> the test script:
> ===
> ===
>  // TEST
> ini_set("date.timezone", "Europe/Amsterdam");
>
> $iter = 1;
> $time = array(
>array("1:30pm", "7:30am", "12:30pm"),
>array("1:30pm", "7:30am", "12:30pm", "4:45pm", "8:15am", "11:00pm"),
>array("1:30pm", "7:30am", "12:30pm", "4:45pm", "8:15am", "11:00pm",
> "4:30am", "6:45am", "12:00pm"),
> );
>
> foreach ($time as $t)
>testIt($t, $iter);
>
>
> // FUNCS
>
> function sortTime1($in_times)
> {
>$time = array();
>foreach ($in_times as $t)
>$time[] = strtotime($t);
>
>sort($time);
>
>$sort_time = array();
>foreach ($time as $t)
>$sort_time[] = date("g:ia", $t);
>
>return $sort_time;
> }
>
> function timeSort2($in)
> {
>static $time = null;
>
>if (!$time)
>$time = time();
>
>$now = array_fill(0, count($in), $time);
>$out = array_map("strtotime", $in, $now);
>array_multisort($out, SORT_NUMERIC, SORT_ASC, $in);
>
>return $in;
> }
>
> function timeSort3($a, $b)
> {
>static $now = null;
>
>if (!$now)
>$now = time();
>
>$a = strtotime($a, $now);
>$b = strtotime($b, $now);
>if ($a == $b)
>return 0;
>
>return $a < $b ? -1 : 1;
> }
>
> function testIt($time, $iter)
> {
>echo "\nNo. of array items = ", count($time), ", no of iterations =
> $iter\n---\n";
>
>$s = microtime(true);
>for ($i = 0; $i < $iter; $i++)
>timeSort2($time);
>$e = microtime(true);
>echo "timeSort1() ran for ".round($e-$s, 6)." seconds \n";
>
>$s = microtime(true);
>for ($i = 0; $i < $iter; $i++)
>timeSort2($time);
>$e = microtime(true);
>echo "timeSort2() ran for ".round($e-$s, 6)." seconds \n";
>
>$s = microtime(true);
>for ($i = 0; $i < $iter; $i++)
>usort($time, "timeSort3");
>$e = microtime

Re: [PHP] Full versus relative URLs

2009-02-16 Thread German Geek
Should be the same as the dns request is cached and a request needs to be
made anyway.

You could argue that relative URLs are less secure, but i cannot really see
why. Well i guess someone can easier steal your source but it doesnt get
much harder with absolute URLs.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Alanis Morissette  - "We'll love you just the way you are if you're
perfect."

2009/2/16 Dotan Cohen 

> > My casual observation seems to indicate that the former will load faster
> > than the latter. But has anyone done any benchmarking on it?
>
> Did you clear the cache between tests? That could explain the speed
> difference.
>
> --
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
>
> א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
> ا-ب-ت-ث-ج-ح-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه‍-و-ي
> А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я
> а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
> ä-ö-ü-ß-Ä-Ö-Ü
>


Re: [PHP] Apache odd behavior

2009-02-16 Thread German Geek
Symfony uses exactly this method for pretty urls. Check it out. Maybe it has
everything you want :). Have a look at symfony's .htaccess rewrite rules at
least. You have a few possibilities here: You can make ur own rewrite for
urls that contain index.php or rewrite
http://mysite.com/alfa/bravo/charlie/deltaas
http://mysite.com/index.php/alfa/bravo/charlie/delta and other urls...

Or in your framework or cms or whatever have helper functions to get the
right urls for images etc. Paths like simply putting  shouldnt be too hard either.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Mike Ditka  - "If God had wanted man to play soccer, he wouldn't have given
us arms."

2009/2/16 Michael A. Peters 

> Paul M Foster wrote:
> > I'm submitting a url like this:
> >
> > http://mysite.com/index.php/alfa/bravo/charlie/delta
>
> Why would you want to do such a thing?
> If you want parameters in the filename without using get, use mod_rewrite
> and explode the page name - and use a delimiter or than a / - IE use an
> underscore, dash, upper case vs lower, etc to indicate your different
> variables.
>
> / has a special meaning in a URL string, I don't understand the motive of
> wanting to use it as a delimiter in a filename. That calls all kinds of
> weird issues (like the one you are experiencing, which is because the
> browser has no way to know index.php is a page - and the browser resolves
> relative URL's - that's not an apache issue)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Back to Basics - Re: [PHP] Re: for the security minded web developer - secure way to login?

2009-02-16 Thread German Geek
yes there are situations like that but then it could just submit the form
(which would happen anyway) and check the plaintext password like normally
if the other mechanism fails. If people have js turned on it would simply
increase security a little. The crucial part is just the sending of the
password. Since it will not be a SSL url security aware ppl will not use
their high priority passwords anyway. It's just for sites like facebook
where you dont have to do money transactions etc.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Fred Allen  - "California is a fine place to live - if you happen to be an
orange."

2009/2/17 Jason Pruim 

>
> On Feb 16, 2009, at 6:11 AM, German Geek wrote:
>
>  Brilliant. Someone who understood my intentions :) It's not only a good
>> exercise but also useful. Once done in PHP and various JS frameworks, we
>> could port it to other languages. Would suggest to support as many as we
>> can
>> because they all have pros and cons. PHP first tho :) . Maybe just good
>> old
>> javascript as a start although the frameworks make it a lot easier. Who on
>> earth has Javascript turned off these days anyway? I don't know anyone who
>> is that paranoid. Sorry if someone here is but i believe if you are scared
>> of javascript you might as well not turn on a computer. There are always
>> going to be security holes.
>>
>>
> There are people who aren't in control of the computer they use. Such as
> anyone in a big corporation... The IT department might have decided to turn
> off javascript support to help protect their companies internal assets.
>
> Or Alot of people who use mobile devices that don't have java support.
>
> All I'm saying is there is a chance that even people who would want to
> leave java on normally might be in situations where they can't have it on.
> :)
>
>
>


Re: [PHP] Re: for the security minded web developer - secure way to login?

2009-02-16 Thread German Geek
well httpus seems like a good idea though. Thats the kind of response i was
hoping for. :-)

Maybe browsers would implement that idea in the future. I like that idea a
lot actually. I mean when you login to your linux server the first time with
openssh, you also have to accept the certificate. In the end you have to
trust something somewhere anyway, even if it's just the programmers of the
browser and other software...

I mean who seriously looks through all the source code of the linux kernel
even though it is open source? And even if someone does it (good on them),
do they understand every single line? A back door could be just a few lines
of hard to understand code, that you might skip. It could even be encrypted
and assembly making it very hard to decipher. Who has that much time and
brains? With windows you have to trust M$ even more because you cannot even
look, and i seriously doubt anyone can disassemble the whole windows OS and
read the code. They would not finish in this life time, not even through
50MB of source code i believe. That's a lot!

A warning at the top of the page like as if there were blocked content would
be sufficient until the user clicks to confirm the validity of of the cert.
The warning could just stay until clicked or don't show me again or
something like that.

FF3 atm changes the whole page when a cert is not authenticated. httpus
could have a small warning but leave the site in shape and let it work. This
would also have to be implemented in web servers though, but why not? Seems
like a brilliant idea to me. The warning could also only be displayed once.
I mean you only get warned once that every form gets sent over an unsecured
network anyway. I bet even you security contious have typed in something
somewhere that you maybe shouldn't have :P. I certainly have...

Anyway, good idea, suggest it to the Apache and FF developers and M$ might
follow at some stage if they believe they can make $$ with it or they would
loose some if they didn't :).

Sorry, this is really loosing its (direct) context to PHP.

But maybe you could even do a layer higher than the protocol and make a PHP
module or something that encrypts requests in some way without the
programmer having to be aware of it. Altho i cant think of any way right now
since the browser does the request. Or maybe it could insert smartly a
javascript and attach an event listener to all forms...

How about a js library that even encrypts? One could use RSA or Diffie
Hellman or similar for key exchange, all in js and php and store the session
key in a cookie, just like the session id... Maybe js is a bit slow for
those kind of calculations though. But maybe worth a thought.

regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Alanis Morissette  - "We'll love you just the way you are if you're
perfect."

2009/2/17 Colin Guthrie 

> 'Twas brillig, and Michael A. Peters at 16/02/09 00:10 did gyre and gimble:
>
>> Colin Guthrie wrote:
>>
>>> 'Twas brillig, and German Geek at 15/02/09 22:32 did gyre and gimble:
>>>
>>>> Please enlighten me why it is so expensive? Is it maybe just the hassle
>>>> of
>>>> setting it up?
>>>>
>>>
>>> The whole thing is about trust. Getting a certificate is nothing if the
>>> system is not backed up by a trust system. If a CA was setup that gave out
>>> certificates willy nilly to all and sundry, then this element of trust is
>>> lost.
>>>
>>
>> Cheap CA's do exist. They have crappy web sites and send you all kinds of
>> junk mail etc. if you use them - but they do exist.
>>
>> I might end up just paying godaddy - I think they charge $12.00 / year,
>> but since I already register through them, they already have my address etc.
>>
>
> Yeah the cheap CA's are IMO actually a problem.
>
> I (personally) think we should have a new system for this scenario:
>
> http:// = totally insecure
> https:// = secure and to a reasonable degree of trust (e.g. no $12.00
> certs!)
> httpus:// = secure but no aspect of trust.
>
> httpus:// would support SSL in exactly the same way as https but the UA
> would simply not display the URL any differently to a standard http
> connection. This would give responsible developers the ability to provide
> SSL services where they only really care about the pipe and not the trust
> aspect.
>
> The problem with the cheap certs is that people do not see much difference
> to the expensive ones and this leads to the possibility of being hijacked.
> The weakest link is always the end user not knowing any better. The High
> Validation certs used by big companies at least show up differently in FF
> now but if you were to replace it with a hijacked non HV cert, there is
> still a go

Re: [PHP] Full versus relative URLs

2009-02-16 Thread German Geek
Tim-Hinnerk Heuer

http://www.ihostnz.com
Mike Ditka  - "If God had wanted man to play soccer, he wouldn't have given
us arms."

2009/2/17 Paul M Foster 

> On Mon, Feb 16, 2009 at 07:39:29PM +0200, Thodoris wrote:
>
> >
> >> Here's a question related to my last post. When specifying a link in a
> >> HTML file (like to the css or an image file), there are two ways of
> >> doing it. One is to simply include the relative path to the file
> >> (relative to the doc root), like:
> >>
> >> /graphics/my_portrait.gif
> >>
> >> Or you can include the full URL, like:
> >>
> >> http://example.com/graphics/my_portrait.gif
> >>
> >> My casual observation seems to indicate that the former will load faster
> >> than the latter. But has anyone done any benchmarking on it?
> >>
> >> Paul
> >>
> >>
> >
> > I am not aware if absolute URLs are faster or not (in case they are
> > there will be such a small difference you cannot probably notice) but
> > IMHO it is a bad practice to use full URLs.
> >
> > Basically because renaming directories or scripts will cause great pain
> > in the ass.
> >
> > Of course resources that are coming outside your own site are needed to
> > use absolute URLs and nobody is assuming that are useless.
>
> Agreed. But here's the real reason, in my case. We develop the pages on
> an internal server, which has the URL http://pokey/mysite.com. When we
> move the pages to the live server at mysite.com, all the URLs would have
> to be rewritten. Ugh.
>

In that case you could change your hosts file (unix: /etc/hosts windows:
%windir%\system32\drivers\etc\hosts) and add a line with the live server's
ip like so:

123.456.789.12 www.example.com

and all your URLs would be right. When you need to check the live domain,
you can simply comment out that line with #.

;) Hope this helps a few people. Saved me a lot of grief.

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


Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++

2009-02-16 Thread German Geek
I thought its an interface as in Common Gateway Interface. :-P

You are right it isn't a specific connection to C. CGI can basically be used
with any language.

A protocol to me is something like TCP/IP or http etc. Like a language
between a network of nodes.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Katharine Hepburn  - "Life is hard. After all, it kills you."

2009/2/17 Stuart 

> 2009/2/16 Thodoris :
> > In addition to this there is an API for C that can be used to code web
> > applications and it is known as CGI (it is provided by many languages)
>
> CGI is a protocol not an API and has no specific connection to C.
>
> -Stuart
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] shell_exec - asynchronous would be cool!

2009-02-18 Thread German Geek
Hi all,

A while ago, i had a problem with shell_exec:

I was writing some code to execute imagemagick to convert a bunch of images.
This could take ages to execute and the page therefore ages to load. The
solution was to get a linux box and append a & at the end to do it in the
background or make a ajax call to a page that does it in batches. The
problem was really that i had to write a file that is then checked against
to know when it was finished... Not very pretty.

Anyway, would it be possible to make a "new" shell_exec_async function in
php that just starts the process, puts it to the background and calls a
callback function or another script with parameters when it finishes? I
guess a callback function is not really going to work because the page needs
to finish execution. It should be possible with PHP forking though.

Anyway, just an idea.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Emo Philips  - "I was the kid next door's imaginary friend."


Re: [PHP] shell_exec - asynchronous would be cool!

2009-02-18 Thread German Geek
Yes, believe it or not, when i was writing this, i thought about a db soln
as well. Just hadnt done it that way back then.

I guess with Linux one could do something like:

shell_exec('{longexecutingprogram -with -params; mysql -uuser -ppass
database query; } &');

Surely it should be possible in windows as well somehow. Does anyone know
how (easily)? I mean i could write a win32 executable that could do it but
that might be overkill.

But still you have to continuously check the database if the value is the
expected which seems kind of unelegant.

Or, you could call a php script at the end like so:
shell_exec('{longexecutingprogram -with -params; php myscript.php with
params; } &');

In myscript.php you could have something like:



Would this work? Maybe one could write a library for that directly in php...

So you could actually have a exec_async function without having to write a
php module or something like that. I would be interested in writing a php
module at some point anyway though. I know c(++), so it should be doable.

Is it possible to retrieve the session variables of a user in php cli?

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
George Burns  - "I would go out with women my age, but there are no women my
age."

2009/2/19 Ashley Sheridan 

> On Thu, 2009-02-19 at 10:30 +1300, German Geek wrote:
> > Hi all,
> >
> > A while ago, i had a problem with shell_exec:
> >
> > I was writing some code to execute imagemagick to convert a bunch of
> images.
> > This could take ages to execute and the page therefore ages to load. The
> > solution was to get a linux box and append a & at the end to do it in the
> > background or make a ajax call to a page that does it in batches. The
> > problem was really that i had to write a file that is then checked
> against
> > to know when it was finished... Not very pretty.
> >
> > Anyway, would it be possible to make a "new" shell_exec_async function in
> > php that just starts the process, puts it to the background and calls a
> > callback function or another script with parameters when it finishes? I
> > guess a callback function is not really going to work because the page
> needs
> > to finish execution. It should be possible with PHP forking though.
> >
> > Anyway, just an idea.
> >
> > Regards,
> > Tim
> >
> > Tim-Hinnerk Heuer
> >
> > http://www.ihostnz.com
> > Emo Philips  - "I was the kid next door's imaginary friend."
>
> What about calling a shell script with the exec call, and as the last
> instruction (or continually throughout its execution) it can update a
> database entry. Your PHP code can then look to see if said entry either
> exists or is in the right state. It should be faster and prettier than
> writing a file.
>
>
> Ash
> www.ashleysheridan.co.uk
>
>


Re: [PHP] Accessors

2009-02-19 Thread German Geek
It's not a bad idea but usually having accessor and mutator methods are used
to validate the data first before writing it to the properties. If you don't
have validation, you might as well set them directly and make them public
and don't really need a generic setter/getter method.

Although, this way, if you decide later on to add a specific getter/setter
for validation you wont need to change the code that accesses the
properties. So, this is a valid approach to save some time.

i believe php should have something like that built in...

In fact actionscript (flash) has quite a clever way of doing this:

With

public class A {
  public function A(){}
  protected var _b:String = "";
  set function b(val:String):void {
if (val.match(/([0-9])*/)) {
  _b = val;
}
  }
  get function b():int {
return int(_b);
  }
  // ...
}

you can write accessors and mutators which are pretty smart.

With

var instance:A = new A();
instance.b = "1234";

you will call the set method and let it validate a string to be a number
only string, so _b can only be set to a string with only numbers.

I found that very neat in actionscript because instead of writing

instance.setB("1234");

you simply write

instance.b = "1234";

and yet you get the benefit of validation. Then it is safe in the getter
method to return an integer (assuming the validation is right).

Java (and a lot of other languages) seems a bit clumsy in that way to be
honest although i like the language as such. A lot of frameworks and class
diagram code generators generate the getter and setter methods for you, but
if you look at the actionscript way, you see it's not really necessary. It
just adds overhead.

But actionscript just makes it short and you can safely make your members
public until you provide a set method and then you wont have to change any
of the code where you are setting (or getting) it, because it stays the
same!

Actionscript 3 has some very nice features like you can loosely type like in
PHP but you can also give strict types like in Java, making it more flexible
while still restrictive if necessary for stability.

Maybe the PHP developers should think about giving optional return types
with :String for example and get and set methods as in actionscript. ... I
know PHP is not actionscript. But a famous German man who was criticised for
changing his mind said: "Why should i keep to my old statement if my
knowlege about the matter has improved?" (or similar..., sorry don't
remember who).

Optional return types wouldn't hurt performance wise would they? And also
they wouldn't even change the current syntax! In fact, isn't everything
strictly typed under the hood anyway?

As far as i know, in php you can already strictly type function parameters
as in:

public function asd(string $mystr) {
  $this->hola = $mystr;
}

Why not make it complete? Or is it?

Sorry for stealing the thread. ;-)

Also, i know php is an interpreted language. But wouldn't it be possible to
write a virtual machine for php and compile byte code... I know, php is not
Java or Actionscript :-P but it could be an add on feature. i guess the eval
wouldn't work then would it? Although eval could still be interpreted...

This would be nice in case you need to protect your intellectual property.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Emo Philips  - "I was the kid next door's imaginary friend."

2009/2/19 Philip Thompson 

> Hi all.
>
> Maybe I'm wanting more Java-like functionality out of PHP, but I don't
> really like getting and setting members directly (even for public members) -
> I'd rather use accessors. This way you can control what is getting set and
> what is returning. However, I also don't really want to create a million
> get/set accessor methods - this is no fun and takes up a lot of space. After
> reading around a little bit, it got me thinking about overloading in PHP
> (which I'm sure we all know is completely different than any other
> language... but that's another day). I didn't want to use the standard __get
> and __set methods because that still leaves me with the same notation for
> getting/setting members. So, instead, I used a close relative of __get and
> __set. Meet brother __call. Could it really be this trivial to get the
> notation I'm wanting? Yes. Yes it is. Ok, enough talking... onto the code.
>
>  class Person
> {
>public $age;
>private $first, $middle, $last;
>
>// Gotta have our construct
>public function __construct () {}
>
>// Here's the fun
>public function __call ($member, $args)
>{
>// Since I know members I want, force the user to only
>// access the ones I've created
>if (property_exists ('Person', $member)) {
>// If args is empty, I must be returning the value
>if (empty ($args)) {
>list ($value) = $this->$member;
>return $value;
>}
>
>// Oh, args is not empty! Set the value
>   

[PHP] XML -> XSLT transformation using XSLTProcessor class

2009-02-20 Thread German Geek
Hi All,

We are trying to import some xml data into the database. My idea was to make
an xslt and then transform the xml to php code which generates the queries
necessary and then gets evaled as php code for the actual import...

Anyway, i got it working (mostly)!

But i need to get the current element name with x-path. So i have the
following:


  some data 1
  some data 2
  some data 3
  some data 4
  some data 5



  //  WORKS and gives the value of
childOfA (e.g. some data 1)
  //... the php code...


In the php code, I need to get the element tag name of the current element,
so either elementA or elementB. How can i get that in an x-path expression?

I know, this is not strictly a php question, but since the project is in php
and this list has a very good response rate, i decided to ask here. I
already looked on the web for hours, but maybe i just don't have the right
keywords.

Please help. Thanks.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
P. J. O'Rourke  - "Everybody knows how to raise children, except the people
who have them."


Re: [PHP] XML -> XSLT transformation using XSLTProcessor class

2009-02-20 Thread German Geek
Thanks a lot. Sorry but 5 minutes after sending this email i figured it out
myself. I didn't know how to answer my own message because i didn't get my
own message... Anyway, this worked for me:


  


Hope this helps someone else...

Thanks again.

Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Bill Watterson  - "There is not enough time to do all the nothing we want to
do."

2009/2/21 Boyd, Todd M. 

> > -Original Message-
> > From: th.he...@gmail.com [mailto:th.he...@gmail.com] On Behalf Of
> > German Geek
> > Sent: Friday, February 20, 2009 9:18 AM
> > To: PHP General list
> > Subject: [PHP] XML -> XSLT transformation using XSLTProcessor class
> >
> > Hi All,
> >
> > We are trying to import some xml data into the database. My idea was to
> > make
> > an xslt and then transform the xml to php code which generates the
> > queries
> > necessary and then gets evaled as php code for the actual import...
> >
> > Anyway, i got it working (mostly)!
> >
> > But i need to get the current element name with x-path. So i have the
> > following:
> >
> > 
> >   some data 1
> >   some data 2
> >   some data 3
> >   some data 4
> >   some data 5
> > 
> >
> > 
> >   //  WORKS and gives the value of
> > childOfA (e.g. some data 1)
> >   //... the php code...
> > 
> >
> > In the php code, I need to get the element tag name of the current
> > element,
> > so either elementA or elementB. How can i get that in an x-path
> > expression?
> >
> > I know, this is not strictly a php question, but since the project is
> > in php
> > and this list has a very good response rate, i decided to ask here. I
> > already looked on the web for hours, but maybe i just don't have the
> > right
> > keywords.
> >
> > Please help. Thanks.
>
> I believe the name() XPath function is what you are looking for. It's been
> a while since I've worked with XPath query strings, but I believe
> ".[name()]" will get you the current element's tag name. Keep in mind: I'm
> not sure if this works with namespaced tags (like ),
> but I have not tested this to be sure.
>
> HTH,
>
>
> // Todd
>


Re: [PHP] Re: mysql_real_escape_string("asdasddas") ??? wtf

2009-02-21 Thread German Geek
Ah, ic. Mh, why wouldn't a function like that function without a db
connection? Does it use the db? Isn't that less efficient? I might just use
str_replace, because i can't think of any way that one could get a sql
injection into

str_replace("'", "\\\'", $value); // might need to replace a literal \ too.

If you can, please enlighten me.

Maybe if they enter something like \c ?? Like one of the mysql special
commands? But if it's inside a string literal??

Thanks a lot, i would have never thought about that.

Will try.

Tim-Hinnerk Heuer

http://www.ihostnz.com
George Burns  - "I would go out with women my age, but there are no women my
age."

2009/2/21 Ross McKay 

> On Sat, 21 Feb 2009 19:19:44 +1300, t...@ihostnz.com wrote:
>
> >Can anyone here tell me why mysql_real_escape_string("asdasddas") returns
> an
> >empty string?
>
> Have you opened a connection to a MySQL database? It won't work without
> an open connection.
> --
> Ross McKay, Toronto, NSW Australia
> "Let the laddie play wi the knife - he'll learn"
> - The Wee Book of Calvin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] headers: setting right for browser to force reload at a certain point in time

2009-02-23 Thread German Geek
Hi All,

We have an application that generates dynamic ebooks. One of the (minor)
problems (but yet annoying) is that when a user comes back to an ebook, they
have to actually delete the cache and reload the page to not get the cached
version which might be wrong because the content or even the flash
application is updated.

It would be neat if we could force a reload of the page, but only with a
special condition like the ebook being updated or the swf. The swf and also
the other resources are not reloaded though, because it is a get request.

Is there a way to force a reload of the browser by maybe changing the
headers? Or do we have to do some fancy stuff like storing a cookie with the
time and sending it back via ajax or something like that?

Just setting the header would be nice...

Maybe the easiest would be to change the link (add a number or something) of
the html page and have a rewrite for all the relative urls as well.

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Henny Youngman  - "When I told my doctor I couldn't afford an operation, he
offered to touch-up my X-rays."


Re: [PHP] headers: setting right for browser to force reload at a certain point in time

2009-02-23 Thread German Geek
Yes, that's what i thought, but with my FF 3.0 the resources (swf,png,jpg)
don't get reloaded. I have to reload the page (after deleting cache).

Something to do with the Apache configuration?

??

Thanks for the reply.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Laurence J. Peter  - "If two wrongs don't make a right, try three."

2009/2/23 Per Jessen 

> German Geek wrote:
>
> > Hi All,
> >
> > We have an application that generates dynamic ebooks. One of the
> > (minor) problems (but yet annoying) is that when a user comes back to
> > an ebook, they have to actually delete the cache and reload the page
> > to not get the cached version which might be wrong because the content
> > or even the flash application is updated.
>
> Deleting the cache should not be necessary, a reload should be enough.
> (it certainly is with Firefox).
>
> > It would be neat if we could force a reload of the page, but only with
> > a special condition like the ebook being updated or the swf. The swf
> > and also the other resources are not reloaded though, because it is a
> > get request.
>
> The request type has nothing to do with it - the browser will do a
> conditional GET if the local copy is expired.  Just set the right
> expiry time on your files when you serve them, then they will
> automatically be checked by the browser.
>
>
> /Per
>
>
> --
> Per Jessen, Zürich (2.8°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] headers: setting right for browser to force reload at a certain point in time

2009-02-23 Thread German Geek
2009/2/23 Per Jessen 

> German Geek wrote:
>
> > Yes, that's what i thought, but with my FF 3.0 the resources
> > (swf,png,jpg) don't get reloaded. I have to reload the page (after
> > deleting cache).
> >
> > Something to do with the Apache configuration?
>
> Hi Tim,
>
> Try loading up just a single file in FF - one of your graphics for
> instance - then hit Ctrl-i to get the info page. That will tell you
> exactly how FF sees the file - expiry time etc.
>

Hi Per,

Thanks. But:

This didn't work. ctrl+i brought up my bookmarks. ?? Do i need a special
plugin/extension? Have web developer etc.

I have Firebug but in the net tab the cached resources don't show up when
reloading the page, i guess because they are not reloaded...

So, i can't think of a way how to see that information when it is in cache.

I had followed some examples on the web talking about the e-tag header which
changes the checksum when the file changes, also i remember setting the
expiry to yesterday and things like that... However it all didn't work.

Anyway, i might just force a reload by changing the links every time
dynamically, although it seems a bit overkill :-S.

Tim-Hinnerk Heuer

http://www.ihostnz.com
P. J. O'Rourke  - "Everybody knows how to raise children, except the people
who have them."


>
> /Per
>
>
> --
> Per Jessen, Zürich (2.6°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] adding whitespace to a timestamp

2009-02-23 Thread German Geek
Maybe the issue is that you are displaying the output in a browser and
spaces are not shown.

Try puttung   instead of a literal space.

Tim-Hinnerk Heuer

http://www.ihostnz.com
Henny Youngman  - "When I told my doctor I couldn't afford an operation, he
offered to touch-up my X-rays."

2009/2/24 Andrew Ballard 

> On Sat, Feb 21, 2009 at 1:28 PM, Eric Sherman 
> wrote:
> > I hoping to add a space between the date and the time in this:
> >
> > $thedate = date('M jS g:i A', $postTIME);
> >
> > i.e, between* jS* and *g:i*
> >
> > I've looked around but can't find anything.
> >
> > Thanks
> >
> > Eric Sherman
> > Multi Media Information
>
> You can put spaces anywhere in that string you want them. What problem
> are you having?
>
> 
> $thedate = date(' M   j  Sg  :   i
>   A   ', $postTIME);
>
> ?>
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] www.soongy.com

2009-03-01 Thread German Geek
Also check this one out: google uses it in gmail:
http://code.google.com/p/jquery-multifile-plugin/downloads/detail?name=multiple-file-upload.zip&can=2&q=

Cheers,
Tim
Tim-Hinnerk Heuer

http://www.ihostnz.com
Groucho Marx  - "I have had a perfectly wonderful evening, but this wasn't
it."

2009/3/2 tedd 

> At 4:17 PM +0200 3/1/09, Nitsan Bin-Nun wrote:
>
>> There is no need to go that far, try to google a bit about swfupload.
>>
>> In short, this is a flash & javascript component that give's you the
>> ability to maintain the upload, get the current speed, get the current
>> amount of uploaded data, etc. It is very simple and works like a charm on a
>> dedi server. There are some issues on shared server sometimes, but even
>> these things are not that much complicated and can be easily solved.
>>
>> HTH,
>>
>
>
> Nitsan
>
> Oh yeah, try this:
>
> http://swfupload.org/documentation/demonstration
>
> and go through the "up" link -- and then try the "See it in action!" link
> and also try the "Demonstration" link. You can even use the
> demo.swfupload.org link, which will provide you with this:
>
> http://demo.swfupload.org/v220beta5/index.htm
>
> All of which is well worth the effort if you're trying to waste your time.
> If their code is as good as their web site, no thanks -- I'll pass.
>
> But if I was to seriously investigate it, I would go directly to Google:
>
> http://code.google.com/p/swfupload/
>
> However, I haven't a clue as to if it works or not.
>
> Cheers,
>
> tedd
>
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] 0.T Java IDE

2009-03-03 Thread German Geek
Give the free eclipse a go. If you need an easy to use gui editor IBM
Websphere (which is also based on Eclipse):
http://www-01.ibm.com/software/websphere/

Eclipse is great, has PDT (PHP Development Tools) too...

Regards,
Tim

Tim-Hinnerk Heuer

http://www.ihostnz.com
Dick Cavett  - "If your parents never had children, chances are... neither
will you."

2009/3/4 Almog Friedman 

> Since I know theres alot of Java progarammers in this list and I don't want
> to sign upo to another mailing list i ask it here
>
> I'm searching for a Java ide (not netbeans, I'm sick of netbeans) which
> does
> gui in swing the best(i come from C# with visual studio and i'm searching
> for something that is as easy and powerful as the visual studio gui editor)
>


[PHP] Fwd: catching up

2009-04-16 Thread German Geek
just in case/tim(e). Yes its me :)
Tim-Hinnerk Heuer

http://www.ihostnz.com
Mitch Hedberg
- "I drank some boiling water because I wanted to whistle."

-- Forwarded message --
From: Tim | iHostNZ 
Date: 2009/4/17
Subject: catching up
To: PHP General list 


Hey guys,

Just trying to catch up to the rest of the world again. Prob wont be able to
read all the php mail.

Just one thing: Maybe PHP should be renamed to PFP (PHP Free Processor) or
something. A recursive acronym sort of suggests that you cannot be free or
break out of this infinite loop. What do you think? It could introduce
another variable call it $f (for FREE of course, nothing else you dirty
minded people), you get the idea.

Btw donations on my website are not abused, but rediculously low. I was
planning to make my CSV to SQL program free software, but without donations
im afraid ill have to fight a court case with the guy who owns me.

i love diet coke or coke zero is even better. advertisement not intended.

Cheers,
Tim
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn
- "A wide screen just makes a bad film twice as bad."


Re: [PHP] array manipulation

2009-04-16 Thread German Geek
soln: YOU NEED A 2 WEEK HOLLIDAY at least! You need to learn to say no.
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn
- "A wide screen just makes a bad film twice as bad."

2009/4/17 PJ 

> The more I get into arrays, the less I understand.
> I have a ridiculously simple task which excapes me completely.
> I need to ouput all fields in 1 column from 1 table in two phases sorted
> alphabetically.
> So, I have the query, I have the results. But since I need to split the
> list into 2 parts, I need indexes. I cannot use the table index as it
> does not correspond to the alphabetical order of the data column. In
> order to get the index, I sort the resulting array and that now gives me
> 34 arrays each containing an array of my results. Wonderful!
> But how do I now extract the arrays from the array?
>
> Here is what I'm trying to do:
>
> $SQL = "SELECT category
>FROM categories
>ORDER BY category ASC
>";
> $category = array();
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
>while ( $row = mysql_fetch_assoc($results) ) {
>$category[$row['category']] = $row;
>}
>sort($category);
>//var_dump($category);
>echo "";
>$count = mysql_num_rows($results);
>$lastIndex = $count/2 -1; echo $lastIndex;
>$ii = 0;
>$cat = '';
> //print_r($category['0']['category']);
>foreach($category as $index => $value) {
>$ii++;
>if ($ii != $lastIndex) {
>$cat .= "$value, ";
>}
>else {
>$cat .= " & $value";
>}
>$catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat);
>//echo "$category";
>echo "
>", $cat, "
>
>" ;
>}
> }
> echo "";
>
> What should I be using in the foreach line?
> Please help!
>
> --
> unheralded genius: "A clean desk is the sign of a dull mind. "
> -
> Phil Jourdan --- p...@ptahhotep.com
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] pup

2009-04-16 Thread German Geek
>From What i learned, yes you can write pup here. Does anyone print this
mailing list? wtf?? i keep overestimating people's intelligence, im sorry!
Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles de 
Gaulle
- "The better I get to know men, the more I find myself loving dogs."

2009/4/17 

> Hi,
>
> I'm new to this list. Can I post PUP questions to this list?
>
> regards,
> -ramesh
>
> P Save a tree...please don't print this e-mail unless you really need to
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to
> this message are intended for the exclusive use of the addressee(s) and may
> contain proprietary, confidential or privileged information. If you are not
> the intended recipient, you should not disseminate, distribute or copy this
> e-mail. Please notify the sender immediately and destroy all copies of this
> message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses. The
> company accepts no liability for any damage caused by any virus transmitted
> by this email.
>
> www.wipro.com
>


Re: [PHP] Sorting times (SOLVED)

2009-05-15 Thread German Geek
Just a draft i thought should not go unnoticed on the list :-) just cleaning
up.
OK,

How about a super efficient soln where each string is only converted once
and a fast sorting algorithm is used:

http://www.ihostnz.com
Fred Allen  - "California is a fine place to live - if you happen to be an
orange."

2009/2/16 Shawn McKenzie 

> tedd wrote:
> > At 9:31 PM -0600 2/14/09, Shawn McKenzie wrote:
> >>
> >> Yeah, hif I had known that you wanted a function where you loop through
> >> your array twice, that would have done it.  Bravo.
> >
> > Shawn:
> >
> > I don't see another way. You go through the array converting string to
> > time (seconds), sort, and then convert back. You have to go through the
> > array more than once.
> >
> > Cheers,
> >
> > tedd
> >
> The "other way", is the most likely ultra-fast solution I posted.
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Script to Compare Database Structures

2009-07-31 Thread German Geek
have you tried mysqldiff?

++Tim Hinnerk Heuer++

http://www.ihostnz.com (should be .org)

Sponsors welcome to put ads under a linked to page. This is not automated
just yet. Only image, swf or preferably text or short html ads, no
animations please. Price negotiable.


2009/8/1 Matt Neimeyer 

> I know I CAN hack something together but I hate to reinvent the wheel.
>
> I want to be able to compare the structure of two different clients
> databases that might be on different servers that are firewalled away
> from each other. Given the two structures it will list all the SQL
> commands needed to make the database structure the same.
>
> In a perfect world on one side you would pull up a PHP page that does
> a "generate structure" which would create a downloadable file which
> you could then upload to the other system which would then give a
> listing of the SQL commands needed to make the local structure match
> the uploaded structure.
>
> Thanks in advance...
>
> Matt
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Searching on AlphaNumeric Content Only

2009-09-02 Thread German Geek
Hi,

It's definitely possible to do when you do it in PHP, but not sure about on
the database side. You could read all records into memory and then iterate
over it with something like:

$toSearch = "4D24487PS"
$charsToIgnore = array('-','+',...);

foreach ($items as $k=>$item) {
  $itemVal = str_replace($charsToIgnore, '', $item);
  if (strcmp(str_replace($charsToIgnore, '', $toSearch), $itemVal) == 0) {
$return = $item;
break;
  }
}

This however might use a lot of memory, but if your DB is a manageable size
it should be ok. You can probably optimise it by iterating over a db result
set instead of reading everything into an array.

Cheers,
Tim
++Tim Hinnerk Heuer++

http://www.ihostnz.com

2009/9/3 

>Is there is a way to search only for the alphanumeric content of
> field in a db?  I have an itemID field that contains item #'s that include
> dashes, forward slashes, etc, and I want people to be able to search for an
> item # even if they don't enter the punctuation exactly.
>
>Here's an example:  let's say there is an itemID of 4D-2448-7PS but
> someone omits the dashes and searches on 4D24487PS.  Is it possible in PHP
> to have the find be successful, even if the search criteria doesn't exactly
> match what's stored in the field?
>
>If this is possible, I'd appreciate it if someone could just point
> me in the right direction so I can read up on it.
>
> Thanks,
> Frank
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] File To Blob Corruption

2009-11-14 Thread German Geek
Hi, Could it have something to do with an eof character being encoded or
something like that? Do you really need to store the files in the DB? It
uses more processing power if stored in the DB because on retrieval, you
have to unescape the string and return it. Modern filesystems are optimised
better for files than databases and storing a filename and returning the
contents is easier to implement than retrieving it from the DB...

http://forums.codewalkers.com/php-applications-45/upload-image-file-to-mysql-as-blob-849194.html

++Tim Hinnerk Heuer++

http://www.ihostnz.com


2009/11/15 Don Wieland 

> Hello,
>
> I am trying to create an UPLOAD page to Update a Images and PDFs into a
> BLOB field in mySQL. The image keeps getting corrupted (it draws a portion
> of the image and the rest is GRAY) We tried it with Safari and Firefox with
> bad results.
>
> Here is the form that is used to browse and select the file.
>
> 
> 
> 
> 
> Upload Thumbnail image
> 
> Please select the thumbnail image, then press Upload.
>  style="margin-top:14px;margin-bottom:14px;text-align:center;width:100%">
>  enctype="multipart/form-data">
> Select Thumbnail:  accept="image/jpeg" />
> 
> 
>  onclick="saveDialog('uploadImage','img','jpg');">  value="Cancel" onclick="cancelDialog('uploadImage','img')">
> 
> 
> 
>
> Here is the QUERY to upload the image (saveDialog.php):
>
> if($_POST['obj'] == "uploadImage") {
> $file =
> $db->real_escape_string(file_get_contents($_FILES['img']['tmp_name']));
> $db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);
>
> Has anyone else ever run into this type of UPDATE error with images and
> PDF? We really need to get this dealt with ASAP.
>
> Thanks!
>
> Don Wieland
> D W   D a t a   C o n c e p t s
> ~
> d...@dwdataconcepts.com
> Direct Line - (949) 305-2771
>
> Integrated data solutions to fit your business needs.
>
> Need assistance in dialing in your FileMaker solution? Check out our
> Developer Support Plan at:
> http://www.dwdataconcepts.com/DevSup.html
>
> Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or
> higher
> http://www.appointment10.com
>
> For a quick overview -
> http://www.appointment10.com/Appt10_Promo/Overview.html
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] uniqid() and repetition of numbers generated

2009-11-14 Thread German Geek
2009/11/14 tedd 

> A
>

Interesting thought. My idea on this is to use the approach used when
replicating a DB. It is similar to the namespace idea if not the same:

Say you have 3 databases, you could use mod 3 numbers for A=0, B=1 and C=2
So on A you would have 0, 3, 6, 9, ... on B 1, 4, 7, 10, ... and on C 2, 5,
8, 11. This way you can just use auto increment and set the increment value
3 and the start value to 0,1,2 respectively. Also, this way you will not run
out of numbers until you run out of integers.

++Tim Hinnerk Heuer++

http://www.ihostnz.com


  1   2   >