Re: [PHP] Friday's Question

2013-09-23 Thread Eric K. Dickinson

54, Only when the surface of the desk is problematic.

On 09/20/2013 12:58 PM, Larry Martell wrote:

On Fri, Sep 20, 2013 at 10:51 AM, Tedd Sperling  wrote:

Hi gang:

Do you use a Mousepad?

My reason for asking is that I've used a Mousepad ever since mice first came 
out (back when they had one ball).

Now that mice are optical (no balls), Mousepads are not really needed -- or so 
I'll told by the college -- you see, they don't provide Mousepads for their 
student's computers.

As such, I wondered what's the percentage of programmers still using a Mousepad?

Secondly, are Mousepads used primarily by older programmers (like me) while 
younger programmers don't use Mousepads, or what?

So -- please respond with:

Age: *
Mousepad: Yes/No


54 Yes



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



[PHP] Does Scope-Resolution Operator Always Follow 'parent'?

2013-03-10 Thread Eric James Michael Ritz

Hello everyone,

I have a question about the `parent` keyword: is there any valid
situation where it can appear without the `::` operator following?

I am asking to fix a bug in php-mode[1] for GNU Emacs.  Consider the
following code:

echo $parent;
echo parent::$foo;
echo $this->parent;

The mode incorrectly highlights `parent` in the final line as if it
were the keyword, but PHP itself treats it as a member of an object.
My idea for fixing this incorrect syntax highlighting is to only treat
`parent` as a keyword if the `::` operator follows it.  But I want to
make sure that this assumption is correct.

Thanks in advanced for any help!


[1]: https://github.com/ejmr/php-mode

--
ejmr
南無妙法蓮華經

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



[PHP] A Recent Emacs Mode for PHP

2012-12-22 Thread Eric James Michael Ritz

Hello everyone,

I do not know how many PHP developers use GNU Emacs for writing code.
But I assume it must be a decent amount since there are multiple PHP
modes for Emacs floating around the Internet.  For months I have
worked to improve one of those modes, what seemed to be the most
popular: http://php-mode.sourceforge.net/

Of course, not all of the improvements are my own work.  Many people
have been kind enough to contribute bug fixes and features.  This is
the version of php-mode which I maintain:

https://github.com/ejmr/php-mode

I simply wanted to share this updated mode in case any developers
using Emacs find it useful.

--
ejmr
南無妙法蓮華經

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



[PHP] output compression when host has disabled mod_deflate, mod_gzip and php_value auto_prepend_file

2012-09-21 Thread edward eric pedersson
Hi

My host, Host Papa (yes, they are rubbish) has disabled mod_deflate,
mod_gzip and php_value auto_prepend_file so can't use them in
.htaccess file. I would move host but I did not realise this was the
case until I wanted to make use of them. I am tied in for three years
so need to find a workaround or live with it.

The site is built using CMS Made Simple (a php based CMS) and I am
using ob_start ("ob_gzhandler"); to compress the html output from the
CMS.

I want to compress the css and javascript external files as well but
without the apache options available I am wondering what other options
I have. The files are not massive, all but one less than 20k. Not sure
how much of a performance gain I will get but I thought it is worth
while asking the question.

One solution I have on my mind is to call a php script that pulls in
the css and js files and compresses the output e.g

http://my.domain.com/stylesheet.php?file=/path/to/stylesheet.css";
/>

stylesheet.php
--


--

Similar code for javascript with different content-type.


A few questions:

1) Will apache cache the full url or the url minus the query parameter?
2) Are there any performance benefits as there is an overhead in
calling the PHP file?
3) If the PHP call is cached is it cached with the file query parameter?

Many thanks for your help.


-- j

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



RE: Re: [PHP] Question about date calculations

2011-12-30 Thread Eric Lommatsch

Actually for what I need this is exactly what i was looking for.  I am 
converting an asp page that was calculating this difference using VBA functions 
and I was trying to duplicate things as they were in that page. 
 

 

Thank you

 


Eric H. Lommatsch
Programmer
Pivotal Data Incorporated  
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927

 


www.pivotaldata.com 

 


er...@pivotaldata.com 

 

 
 
-Original message-
From: Fatih P. 
Sent: Thu 29-12-2011 16:16
To: ad...@buskirkgraphics.com; 
CC: 'Frank Arensmeier' ; 'Eric Lommatsch' 
; php-general@lists.php.net; 
Subject: Re: [PHP] Question about date calculations



On 12/30/2011 12:19 AM, ad...@buskirkgraphics.com wrote: 
-Original Message- From: Fatih P. [ mailto:fatihpirist...@gmail.com ] 
Sent: Thursday, December 29, 2011 5:10 PM To: Frank Arensmeier Cc: Eric 
Lommatsch; php-general@lists.php.net Subject: Re: [PHP] Question about date 
calculations On Thu, Dec 29, 2011 at 11:40 PM, Frank Arensmeier 
 wrote: 

29 dec 2011 kl. 22.22 skrev Eric Lommatsch: 

So far in looking at the functions that are available at 
http://www.php.net/manual/en/ref.datetime.php I have not been able 

to 

figure 

out how to do what I need to do. Below is a snippet showing 

approximately 

what I am trying to do. 

On the same page you are referring, there are plenty of examples on 

how to 

calculate the difference between two dates. Choose one and see if it 

fits 

your bill. Or is there any particular reason why you're writing your 

"own" 

function? http://www.php.net/manual/en/ref.datetime.php#78981 /frank -- PHP 
General Mailing List ( http://www.php.net/ ) To unsubscribe, visit: 
http://www.php.net/unsub.php 

since you have everything in database tables why not to do this calculation on 
database side which would be much appropriate place ? /* columns date_start = 
'2011-02-08'; date_end = ' 2011-03-04'; */ select DATEDIFF(date_end, 
date_start); http://dev.mysql.com/doc/refman/5.5/en/date-and-time - 
functions.html#function_datediff 

I looked at this answer and see the date is from an array of a database and not 
2 fields with in the table. While the DATEDIFF() is very useful in queries this 
will not help you unless both fields are in the table. Try this example 
$dteStartDate[$intCnt] = new DateTime($row[10]); $dteEndDate[$intCnt] =new 
DateTime($row[11]); $interval = 
$dteStartDate[$intCnt]->diff($dteEndDate[$intCnt]); echo 
$interval->format('%R%a days'); 

well then look deeper in the question:  

"I have a page I am trying to create where I am comparing the values of two
MySQL date fields with the current date. One of the MySQL Date fields is a 
class start date, the other is the class end date."

all needs to do is modify his query.



RE: [PHP] Question about date calculations

2011-12-30 Thread Eric Lommatsch

When I try this method:

 

$interval = $dteStartDate[$intCnt]->diff($dteEndDate[$intCnt]); I get the 
following error when I run the page: 

" Fatal error : Call to undefined method DateTime::diff() in 
/var/www/evalHomeLime.php on line 254"   
 

 

Thank you

 


Eric H. Lommatsch
Programmer
Pivotal Data Incorporated  
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927

 


www.pivotaldata.com 

 


er...@pivotaldata.com 

 

 
 
-Original message-
From: ad...@buskirkgraphics.com
Sent: Thu 29-12-2011 16:07
To: 'Fatih P.' ; 'Frank Arensmeier' 
; 
CC: 'Eric Lommatsch' ; php-general@lists.php.net; 
Subject: RE: [PHP] Question about date calculations


> -Original Message-
> From: Fatih P. [mailto:fatihpirist...@gmail.com]
> Sent: Thursday, December 29, 2011 5:10 PM
> To: Frank Arensmeier
> Cc: Eric Lommatsch; php-general@lists.php.net
> Subject: Re: [PHP] Question about date calculations
> 
> On Thu, Dec 29, 2011 at 11:40 PM, Frank Arensmeier
> wrote:
> 
> > 29 dec 2011 kl. 22.22 skrev Eric Lommatsch:
> >
> > > So far in looking at the functions that are available at
> > > http://www.php.net/manual/en/ref.datetime.php I have not been able
> to
> > figure
> > > out how to do what I need to do.  Below is a snippet showing
> > approximately
> > > what I am trying to do.
> >
> > On the same page you are referring, there are plenty of examples on
> how to
> > calculate the difference between two dates. Choose one and see if it
> fits
> > your bill. Or is there any particular reason why you're writing your
> "own"
> > function?
> >
> > http://www.php.net/manual/en/ref.datetime.php#78981
> >
> > /frank
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> since you have everything in database tables why not to do this
> calculation
> on database side which would be much appropriate place ?
> 
> /* columns
> date_start = '2011-02-08';
> date_end = ' 2011-03-04';
> */
> 
> select DATEDIFF(date_end, date_start);
> 
> http://dev.mysql.com/doc/refman/5.5/en/date-and-time-
> functions.html#function_datediff


I looked at this answer and see the date is from an array of a database and not 
2 fields with in the table.
While the DATEDIFF() is very useful in queries this will not help you unless 
both fields are in the table.

Try this example

$dteStartDate[$intCnt] = new DateTime($row[10]);
$dteEndDate[$intCnt] =new DateTime($row[11]);
$interval = $dteStartDate[$intCnt]->diff($dteEndDate[$intCnt]);
echo $interval->format('%R%a days');










RE: Re: [PHP] Question about date calculations

2011-12-30 Thread Eric Lommatsch

Hello Frank,
 

As far as I know I am not doing anything in terms of trying to write or use my 
own function.  What I am trying to do is use what PHP provides.  

 

Thank you

 


Eric H. Lommatsch
Programmer
Pivotal Data Incorporated  
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927

 


www.pivotaldata.com 

 


er...@pivotaldata.com 

 

 
 
-Original message-
From: Frank Arensmeier 
Sent: Thu 29-12-2011 15:25
To: Eric Lommatsch ; 
CC: php-general@lists.php.net; 
Subject: Re: [PHP] Question about date calculations

29 dec 2011 kl. 22.22 skrev Eric Lommatsch:

> So far in looking at the functions that are available at
> http://www.php.net/manual/en/ref.datetime.php I have not been able to figure
> out how to do what I need to do.  Below is a snippet showing approximately
> what I am trying to do.

On the same page you are referring, there are plenty of examples on how to 
calculate the difference between two dates. Choose one and see if it fits your 
bill. Or is there any particular reason why you're writing your "own" function?

http://www.php.net/manual/en/ref.datetime.php#78981

/frank



[PHP] Question about date calculations

2011-12-29 Thread Eric Lommatsch
Hello List,

 

I am using PHP version 5.2.6.

 

I have a page I am trying to create where I am comparing the values of two
MySQL date fields with the current date. One of the MySQL Date fields is a
class start date, the other is the class end date.

 

First I need to calculate the number of days between class start and end
date. Then based on the number of days between these to dates I have to find
out how close the current date is to the class end date.

 

So far in looking at the functions that are available at
http://www.php.net/manual/en/ref.datetime.php I have not been able to figure
out how to do what I need to do.  Below is a snippet showing approximately
what I am trying to do.

 

=($dteEndDate[$i]-7) &&
$dteCheckDate<=($dteEndDate[$i]+1)) && $intDayCnt<16)

...

?>

 

My start date is 12/26/2011, the end date 1/8/2012 so the value for
&intDayCnt should be 13, but it is coming up as 0.

 

Also the check date which is 12/29/2011 is being calculated as after my end
date.  Can someone point me in the direction of what I need to do to have
the comparisons I am doing work.

 

Eric Lommatsch. 



Re: [PHP] Re: Preferred Syntax

2011-12-17 Thread Eric Butera
On Sat, Dec 17, 2011 at 12:59 AM, Adam Richardson  wrote:
> On Fri, Dec 16, 2011 at 11:53 PM, Eric Butera  wrote:
>>
>> To all the people who responded to this thread:
>> It is 2011 - please stop writing code like this.
>>
>> To the OP:
>> I'm glad you're asking questions and realizing you're not happy with
>> your current abilities and suspect there's a better way.  I've read
>> the replies in this thread and feel a bit let down.  Use a templating
>> language - yes, I understand that is what php is for - but I won't go
>> into it.  You should not be echoing, printing, or any other method of
>> concatenating html dealing with escaping quotes inside your php logic
>> code.  Please separate your concerns.
>>
>> Not sure what that means?  That's OK!  If you want to move forward,
>> look up how modern frameworks deal with this issue using their views
>> or template views.  You don't have to use a framework if you do not
>> want to, that's perfectly fine.  If it works, it works.  But in the
>> end, it the separation of logic and html is essential to code
>> maintenance.
>
>
> Eric,
>
> There are many posters to this list, and there exists a broad range of
> programming styles and abilities. I'll bet you're a competent programmer,
> and that you've worked hard to hone your craft. It takes passion and drive
> to improve one's skill set. However, I'd encourage you to focus that passion
> on the list in a way that facilitates the growth of those with questions
> whilst staying true to their current, specific needs.
>
> Frankly, every answer on the list could begin with the suggestion that they
> just use a framework. The list is here to help build up the entire skill set
> of PHP developers.
>
> Let's reexamine the original post:
>
>> Hello all.
>>
>> Can someone tell me which of the following is preferred and why?
>
>
> Use of the word "Which" implies that there were a closed set of options they
> wanted to consider, although we did offer some others, but they all stayed
> relatively true to his original options.
>
>>
>>
>>  echo "> href='/mypage.php/$page_id'>$page_name";
>>  echo "> href='/mypage.php/".$page_id."'>".$page_name."";
>
>
> Simple.
>
> Please note there is no logic anywhere in this example. PHP is truly serving
> merely as a templating language here. So, while I agree with the general
> notion that logic should not be intermingled with markup, this particular
> example does not serve as the anti-pattern you suggest.
>
> Also, note that we aren't sure where the $page_id and $page_name variables
> are coming from. In instances where these are set manually within the script
> (like a view variables at the top of the page), there's no need to escape
> anything. That said, you're right, if the data is coming from somewhere
> else, escaping should happen, but there's not enough information to infer
> that, as you say, "You should not be echoing, printing, or any other method
> of concatenating html dealing with escaping quotes inside your php
> logic code."
>
>>
>>
>> When I come across the above code in line 1, I have been changing it to
>> what you see in line 2 for no other reason than it delineates out better in
>> BBEdit.  Is this just a preference choice or is one method better than the
>> other?
>
>
> The above statement suggests there's an existing codebase that was being
> worked through. In this light, the answers mostly focused on answering the
> OP's original question, realizing that this was existing code that he was
> refactoring lightly as he goes.
>
> This is not to say that I disagree with all that you said, as I actually
> developed my own framework that:
>
> Cleanly separates PHP from HTML to avoid the intermingling of logic and
> presenation:
> http://nephtaliproject.com/documentation/markup/
> Automatically handles output escaping, input validation:
> http://nephtaliproject.com/documentation/examples/contact.php
> And lots of other features that coincide with the general focus of your
> words.
>
> Given that work, I think it's fair to say that I do agree with several of
> your general points for web development overall. However, this question
> wasn't a big picture question on how to do web development with PHP. It was
> a simple question that was answered in a helpful, specific manner by several
> on the list.
>
> Adam
>
> --
> Nephtali:  A simple, flexible, fast, and security-focused PHP framework
> http://nephtaliproject.com

Hi Adam,

Thanks for the reply, noted!  I was coming from the angle that I've
had to deal with a lot of code that is 2000 lines of
php/html/javascript inside heredocs, mixed quote escaping, etc.  I was
hoping to prevent that from becoming a new thing in this persons code
if that was the case.  Apologies for assuming.

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



Re: [PHP] Re: Preferred Syntax

2011-12-16 Thread Eric Butera
On Thu, Dec 15, 2011 at 5:46 PM, Ross McKay  wrote:
> Jim Lucas wrote:
>
>>I second this example, with one minor change, I would add '{' and '}' around
>>variables.
>>
>>echo <<>>   href="/mypage.php/{$page_id}">{$page_name}
>>HTML;
>>
>>This works for $variables, $objects, and variable functions calls.  But 
>>doesn't
>>work if you try to call functions directly (bummer).
>
> In fact, we are in agreement here :) I was just simplifying for the
> example at hand. And as for calling functions directly, also add
> constants :(
>
> However, it's easy enough to assign a constant to a variable and embed
> it in a HEREDOC, and also easy to wrap a function in a method,
> especially when your HEREDOC is within a method itself:
>
> define('MSG', 'My name is');
>
> class X {
>  function html($text) {
>    return htmlspecialchars($text);
>  }
>
>  function output($name) {
>    $msg = MSG;
>    echo << $msg {$this->html($name)}
> HTML;
>  }
> }
>
> $x = new X();
> $x->output('silly "rockstar" name like <&>');
>
>>[...]
>>This is why I like heredoc syntax over pretty much everything else.
>
> Concur!
> --
> Ross McKay, Toronto, NSW Australia
> "Pay no attention to that man behind the curtain" - Wizard of Oz
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

To all the people who responded to this thread:
It is 2011 - please stop writing code like this.

To the OP:
I'm glad you're asking questions and realizing you're not happy with
your current abilities and suspect there's a better way.  I've read
the replies in this thread and feel a bit let down.  Use a templating
language - yes, I understand that is what php is for - but I won't go
into it.  You should not be echoing, printing, or any other method of
concatenating html dealing with escaping quotes inside your php logic
code.  Please separate your concerns.

Not sure what that means?  That's OK!  If you want to move forward,
look up how modern frameworks deal with this issue using their views
or template views.  You don't have to use a framework if you do not
want to, that's perfectly fine.  If it works, it works.  But in the
end, it the separation of logic and html is essential to code
maintenance.

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



Re: [PHP] Sniping on the List

2011-11-15 Thread Eric Butera
On Mon, Nov 14, 2011 at 12:51 PM, George Langley  wrote:
>        Am concerned over the number of posts that appear to be from people 
> trying to over-inflate their self-importance.
>        If you are the world's best coder, then help those of us who aren't. 
> If you happen to know a better way to do something that I'm struggling with, 
> then please share it. But if you just want to take pot shots at us, then 
> please keep your comments to yourself.
>
>        To that end, I wish to thank Ashley Sheridan, Daniel P. Brown, Tedd 
> Sperling and Tommy Pham, to name but just a few of those who have submitted 
> incredibly-helpful posts, that I have kept for reference. Your contributions 
> are very much appreciated - thanks.
>
>
> George Langley
> Interactive Developer
>
> www.georgelangley.ca


You should have seen some of the lambasting that used to pass as
discourse back when this list had traffic.  :]

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



Re: [PHP] Friday Distraction

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 7:24 PM, Nathan Nobbe  wrote:
>
>
> On Fri, Oct 28, 2011 at 5:23 PM, Eric Butera  wrote:
>>
>> On Fri, Oct 28, 2011 at 7:07 PM, Daniel Brown  wrote:
>> > On Fri, Oct 28, 2011 at 18:36, Nathan Nobbe 
>> > wrote:
>> >> Hi gang,
>> >>
>> >> Thinking database i/o would be the slowest part of a request in your
>> >> new zf
>> >> / amf app?
>> >>
>> >> Leave it to Zend_Amf to burn more cycles marshaling the protocol!
>> >>
>> >>
>> >> http://s289.photobucket.com/albums/ll238/quickshiftin/?action=view¤t=ScreenShot2011-10-24at74724PM.png
>> >
>> >    Ends up looking startlingly like the original Sim City.
>> >
>> > --
>> > 
>> > Network Infrastructure Manager
>> > http://www.php.net/
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>> kcachegrind is great.
>>
>> SimCity is great!  Just the other day I was thinking about that
>> soundtrack it played over the PC speaker, hilarious.
>
> Agreed, the only thing that isn't great in this context .. Zend_Amf, haha!
> -nathan
>

I saw your post on that the other day - looks like there's a native
php extension you might look into.  The author was quite proud of the
hasty response it was capable of, going as far as to say his library
was faster than flash can decode it.

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



Re: [PHP] Friday Distraction

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 7:07 PM, Daniel Brown  wrote:
> On Fri, Oct 28, 2011 at 18:36, Nathan Nobbe  wrote:
>> Hi gang,
>>
>> Thinking database i/o would be the slowest part of a request in your new zf
>> / amf app?
>>
>> Leave it to Zend_Amf to burn more cycles marshaling the protocol!
>>
>> http://s289.photobucket.com/albums/ll238/quickshiftin/?action=view¤t=ScreenShot2011-10-24at74724PM.png
>
>    Ends up looking startlingly like the original Sim City.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

kcachegrind is great.

SimCity is great!  Just the other day I was thinking about that
soundtrack it played over the PC speaker, hilarious.

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 3:29 PM, Daniel Brown  wrote:
> On Fri, Oct 28, 2011 at 13:25, Jim Long  wrote:
>>
>> Eric:
>>
>> Thanks for your reply.
>>
>> "process row here" is a comment.  It doesn't do anything.  The
>> script, exactly as shown, runs out of memory, exactly as shown.
>
>    My response presumes that you're planning on placing something
> into this comment area, in which the memory will only further
> increase.  If *presumed* should be replaced by *ASSumed* in this case,
> skip mysql_unbuffered_query() and go straight for mysql_num_rows().
> Do not pass GO.  Do not collect $200.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>

I was glad to learn what comments were.

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 12:38 PM, Jim Long  wrote:
> I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
>
> The script below is designed to be able to WHILE it's way through
> a MySQL query result set, and process each row.
>
> However, it runs out of memory a little after a quarter million
> rows.  The schema fields total to about 200 bytes per row, so
> the row size doesn't seem very large.
>
> Why is this running out of memory?
>
> Thank you!
>
> Jim
>
> 
> $test_db_host = "localhost";
> $test_db_user = "foo";
> $test_db_pwd  = "bar";
> $test_db_name = "farkle";
>
> $db_host = $test_db_host;
> $db_user = $test_db_user;
> $db_name = $test_db_name;
> $db_pwd  = $test_db_pwd;
>
> if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
>        die( "Can't connect to MySQL server\n" );
>
> if (!mysql_select_db( $db_name, $db_conn ))
>        die( "Can't connect to database $db_name\n" );
>
> $qry = "select * from test_table order by contract";
>
> if ($result = mysql_query( $qry, $db_conn )) {
>
>        $n = 0;
>        while ($row = mysql_fetch_assoc( $result )) {
> // process row here
>                $n++;
>        } // while
>
>        mysql_free_result($result);
>        echo "$n\n";
>
> } else {
>
>        die( mysql_error() . "\n" );
>
> }
>
> ?>
>
>
> PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
> allocate 20 bytes) in xx3.php on line 24
>
> Line 24 is:
>
>    24          while ($row = mysql_fetch_assoc( $result )) {
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Not sure what is happening inside "process row here," but I'm sure
that is where your issue is.  Instead of building some giant structure
inside of that while statement you should flush it out to the screen.

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



Re: [PHP] Friday Distraction

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 12:02 PM, Daniel Brown  wrote:
> On Fri, Oct 28, 2011 at 11:51, Eric Butera  wrote:
>>
>> Mr Brown,
>>
>> You're not going to try and pawn this thread off as the Friday
>> Distraction, are you?
>
>    No, I'm waiting for someone else to set themselves on fire in
> front of the crowd of onlookers this week.
>
>    My email this week would otherwise have been nothing but a picture
> of a hydraulic jack, useful for lifting the respective rocks from
> those who have been living beneath them.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>

That doesn't sound controversial enough.  :)

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



Re: [PHP] Friday Distraction

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 11:16 AM, Tedd Sperling  wrote:
> On Oct 28, 2011, at 9:43 AM, Stuart Dallas wrote
>> On 28 Oct 2011, at 12:54, Daniel Brown wrote:
>> On Fri, Oct 28, 2011 at 05:03, Adam Richardson  wrote:
 Well, Daniel,
 I'll bet you never thought that your "Friday Distraction" would elicit such
 a broad range of responses AND keep the commentary coming right through to
 the next Friday.
 Nice :)
>>>
>>>   This is nothing compared to how it used to be ~2007-08.  ;-P
>>
>> Ahh, the "good old days"!
>
> To all:
>
> To me -- these ARE the "good old days".
>
> Even though the economy is in the dumpster, quantity of business is down, and 
> clients are harder to please, this time has presented me with more enjoyable 
> challenges than ~2007-8. Of course, this could be just me trying to keep 
> current with technology while not realizing I am falling behind. But, it 
> feels like things are better now -- sometimes ignorance is bliss. Strive to 
> be happy.
>
> Cheers,
>
> tedd
>
> _
> t...@sperling.com
> http://sperling.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Mr Brown,

You're not going to try and pawn this thread off as the Friday
Distraction, are you?

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



[PHP] Re:

2011-09-22 Thread Eric
Thanks Very much I used,
preg_match('/[[:punct:]]/', $_POST['username']) !== 0
and it works without errors. The reason I can't just use
is_file which I wish I could is because windows doesn't allow question marks
or some wierd character. It decides to not allow php to make the file if there
are odd  ball characters. It is a very unfortunate mistake in my code that I
wish php would ignore and just make the file "?".

[PHP] RE: How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Eric
if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) {
echo "";
echo "Username must only contain A-Z and 0-9";
include("register.html");
exit;
}

I used the code above but I now get this error message

Warning: preg_match() [function.preg-match]: Unknown modifier '^' in 
C:\Documents and 
Settings\iceweasel\Desktop\XAMPP\relik.ath.cx\forum\register.php on line 2

I don't like to run php with errors off so I wanna ask how I can fix this.

[PHP] How can I check for characters in a $_POST[] variable?

2011-09-22 Thread Eric
I have this problem when using php because my computer recognizes
the characters "." and ".." as an existing file when I use file_exists. Also
I want to check $_POST["username"] for characters other then A-Z a-z and 0-9.
If it contains anything other then, I would like to prompt the user but
I can't seam to use foreach properly and I don't know how to itterate
through the post variable with a for loop while loop or do while loop.

Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-14 Thread Eric Butera
On Wed, Sep 14, 2011 at 4:12 AM, Dotan Cohen  wrote:
> On Wed, Sep 14, 2011 at 06:05, chetan rane  wrote:
>> Hi,
>>
>> There are 2 peoblems with subselect
>>
>> 1. You cant use a limit on the nested select
>> 2. Id the number of elements in the in clause exceeds the subselect buffer
>> you will run into performance issues ans eventually you query will be
>> doomed. Inner joins in,this is the best option for this . You can use a temp
>> table for this
>>
>
> Thanks Chetan. I will keep that in mind if I ever get around to
> learning about subselects.
>
> Have a great day!
>
> --
> Dotan Cohen
>
> http://gibberish.co.il
> http://what-is-what.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Just out of curiosity, where are these ids coming from?  Doing a raw
implode on them like that is a sql injection vuln.

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



Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread Eric Butera
Oh no, he stole your internet points!


On Tue, Sep 13, 2011 at 10:44 AM, Ashley Sheridan
 wrote:
>
>
> yeer tai  wrote:
>
>>
>>
>>select * from table where userID in(1,2,3,etc)
>>
>>
>>
>>> From: a...@ashleysheridan.co.uk
>>> Date: Tue, 13 Sep 2011 15:29:26 +0100
>>> To: dotanco...@gmail.com; php-general@lists.php.net
>>> Subject: Re: [PHP] Querying a database for 50 users' information: 50
>>queries or a WHERE array?
>>>
>>>
>>>
>>> Dotan Cohen  wrote:
>>>
>>> >I have a MySQL database table with about 10,000 rows. If I want to
>>> >query for 50 specific users (so no LIMIT ORDER BY) then I seem to
>>have
>>> >these choices:
>>> >
>>> >1) SELECT * FROM table
>>> >This will pull in all 10,000 rows, not nice!
>>> >
>>> >2) foreach ($user as $u) { mysql_query("SELECT * FROM table WHERE
>>> >userID=".$u);  }
>>> >This will lead to 50 queries, again not nice! (maybe worse)
>>> >
>>> >3) foreach ($user as $u) { $whereClause+=" OR userID=".$u; }
>>> >This makes a huge SQL query. However, this is the method that I'm
>>using
>>> >now.
>>> >
>>> >Is there some sort of array that can be passed in the WHERE clause,
>>> >containing all the userID's that I am interested in?
>>> >
>>> >Thanks!
>>> >
>>> >--
>>> >Dotan Cohen
>>> >
>>> >http://gibberish.co.il
>>> >http://what-is-what.com
>>> >
>>> >--
>>> >PHP General Mailing List (http://www.php.net/)
>>> >To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>> SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc)
>>>
>>> Much smaller than what you proposed in #3, and easier to make if your
>>user is list is already an array.
>>>
>>> Thanks,
>>> Ash
>>> http://www.ashleysheridan.co.uk
>>> --
>>> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>
>
> Erm, that's funny that you replied with the exact same answer as I gave, just 
> top-posted on my reply...
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
> --
> 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] Re: Stop PHP execution on client connection closed

2011-09-13 Thread Eric Butera
On Tue, Sep 13, 2011 at 4:01 AM, Marco Lanzotti  wrote:
> Il 13/09/2011 09:39, vikash.i...@gmail.com ha scritto:
>>
>> You can use ob_start() to start output buffering and ob_end_flush() to send
>> some data in the middle of script  - that way  your php script will send
>> some data to the client earlier than finishing execution and hence detect
>> the aborted connection.
>
> The question is: how can I send data to client until I'm waiting for
> query execution? PHP thread support is not available in Apache enviroment.
>
> Bye,
> Marco
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Flush all buffers you have.  Sometimes you have to do nasty hacks like
send a certain number of characters.  Execution will still continue
along after your buffers are send if it is still blocking for a query.

You might have better luck if you search for 'comet' or 'long polling.'

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



Re: [PHP] PHP cron job optimization

2011-09-12 Thread Eric Butera
On Mon, Sep 12, 2011 at 9:37 AM, Igor Escobar  wrote:
> Other good point is: always set a timeout connection when you're getting the
> RSS data to avoid your thread get stuck unnecessary. Use cURL (is much more
> faster then file_get_contents).
>
> Multithreading in PHP with cURL http://devzone.zend.com/article/3341
>
>
> Regards,
> Igor Escobar
> *Software Engineer
> *
> + http://blog.igorescobar.com
> + http://www.igorescobar.com
> + @igorescobar 
>
>
>
>
>
> On Mon, Sep 12, 2011 at 10:05 AM, Igor Escobar wrote:
>
>> Use PHP threads. Do the job separately.. in parts... in other words... you
>> can't read all them at once.
>>
>> You can read a little more about php multithreading here:
>> http://blog.motane.lu/2009/01/02/multithreading-in-php/
>>
>> You can use a non-relational database like mongo or couchdb to manage where
>> you stop and where you have to look back to the RSS feed as well.
>>
>> []'s
>>
>> Regards,
>> Igor Escobar
>> *Software Engineer
>> *
>> + http://blog.igorescobar.com
>> + http://www.igorescobar.com
>> + @igorescobar 
>>
>>
>>
>>
>>
>>
>> On Sat, Sep 10, 2011 at 10:37 PM, Stuart Dallas  wrote:
>>
>>> On 10 Sep 2011, at 09:35, muad shibani wrote:
>>>
>>> > I want to design an application that reads news from RSS sources.
>>> > I have about 1000 RSS feed to collect from.
>>> >
>>> > I also will use Cron jobs every 15 minutes to collect the data.
>>> > the question is: Is there a clever way to collect all those feed items
>>> > without exhausting the server
>>> > any Ideas
>>>
>>> I designed a job queuing system a while back when I had a similar problem.
>>> You can read about it here: http://stut.net/2009/05/29/php-job-queue/.
>>> Set that type of system up and add a job for each feed, set to run every 15
>>> minutes. You can then watch the server and tune the number of concurrent job
>>> processors so you get the optimum balance between load and speed.
>>>
>>> -Stuart
>>>
>>> --
>>> Stuart Dallas
>>> 3ft9 Ltd
>>> http://3ft9.com/
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>

Thread != Multi Process.

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



Re: [PHP] PHP cron job optimization

2011-09-10 Thread Eric Butera
On Sat, Sep 10, 2011 at 1:47 PM, Sean Greenslade  wrote:
> On Sat, Sep 10, 2011 at 4:35 AM, muad shibani wrote:
>
>> I want to design an application that reads news from RSS sources.
>> I have about 1000 RSS feed to collect from.
>>
>> I also will use Cron jobs every 15 minutes to collect the data.
>> the question is: Is there a clever way to collect all those feed items
>> without exhausting the server
>> any Ideas
>> Thank you in advance
>>
>
> Do them one at a time. Fetching web pages isn't a particularly taxing job
> for any decent server.
>
> My advice is just to try it. Even if you solution isn't 'elegant' or
> 'clever,' if it works and doesn't bog down the server, that's a win in my
> book.
>
> --
> --Zootboy
>
> Sent from my PC.
>

Traversing the internet is one of the most expensive IO operations
that can be performed.  The OP should try and split the work into
several processes and utilize async connections via a mechanism like
curl_multi [1].  Doing 1,000 connections one at a time is abysmal if
you're blocked for even 3 seconds per connection.

I'd work by making a two step process that has one cron job for
constantly fetching/updating feeds into a store & then another process
that constantly checks for updates inside aforementioned store.

[1] http://us3.php.net/manual/en/function.curl-multi-add-handle.php

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



Re: [PHP] Upgrade or Die?

2011-06-26 Thread Eric Butera
On Sat, Jun 25, 2011 at 12:13 AM,   wrote:
> The message for Netscape was very clear, the development community refused to 
> write for it they had started a precedence that could not be forgotten.
> I say communities will not forget this act and remove the browser from their 
> systems rather than be forced into an update for security reasons.
>
> Honestly, rarely do any of my customers use FF, and their reasons are 
> justified in their mind, so I do not argue the point.
>
> This is another reason for security personnel, to credit their policies in 
> denying FF on their network the same as they did with Netscape.
>
>
>
>
> Richard L. Buskirk
> Senior Software Engineer/Systems Administrator
>
> You can’t grow your business with systems that are on life support...
>
> -Original Message-
> From: Richard Quadling [mailto:rquadl...@gmail.com]
> Sent: Friday, June 24, 2011 5:38 PM
> To: a...@ashleysheridan.co.uk
> Cc: Andy McKenzie; php-general@lists.php.net
> Subject: Re: [PHP] Upgrade or Die?
>
> On 24 June 2011 19:39, Ashley Sheridan  wrote:
>> On Fri, 2011-06-24 at 13:38 -0400, Andy McKenzie wrote:
>>
>>> On Fri, Jun 24, 2011 at 1:30 PM,   wrote:
>>> > Chrome. Enough said. Now, if we can only convince the rest of the world 
>>> > ...
>>> >
>>>
>>> Ugh.  I can't stand Chrome.  Of course, I gave up on Firefox years ago
>>> and went back to Opera, so it doesn't bother me when Firefox does
>>> something weird like this...
>>>
>>> -Andy
>>>
>>
>>
>> Meh, I'm still using 3.6 on my main computer and 3.5 on my laptop. Using
>> Fx4 at work, and I have to say, I prefer 3.6. Fx4 is slower, prone to
>> crashing and a bit of a memory hog. I really hope Mozilla doesn't go the
>> way of Google and create loads of new versions dropping support for the
>> older ones as it goes, even if the 'older' versions are barely that old
>> at all.
>
> That pattern of behaviour sounds exactly like Netscape all those years ago.
>
>
>
> --
> Richard Quadling
> Twitter : EE : Zend : PHPDoc
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
>
> --
> 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
>
>

Just to throw my two pennies into this - I believe that all browsers
should auto-upgrade.  The browser has become the most important
application on desktops and it is remiss of all parties involved to
allow the masses to use exploitable out-dated software.  If someone is
paranoid about their supposed privacy, afford them the luxury of
finding ways to use software that has known defects.  I entreat you to
consider how much time and pain this would have prevented over the
last decade.

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



Re: [PHP] Doctrine madness!

2011-06-17 Thread Eric Butera
On Fri, Jun 17, 2011 at 3:19 PM, Jim Lucas  wrote:
> On 6/16/2011 3:15 PM, Nathan Nobbe wrote:
>> what it really amounts to is php is good at doing 1 thing and 1 thing only,
>> generating web pages.  for anything else, including command line scripts
>> that run for more than 30 seconds, choose an actual programming language or
>> be prepared to deal w/ hacky, disgusting workarounds.
>>
>
> Nathan,
>
> I would have to disagree with your statement about using PHP for applications
> that take more then 30 seconds or CLI scripts.
>
> I have a daemon (read: scripts) that I wrote using PHP.  It listens on a few 
> UDP
> sockets and maintains an open connection to mysql.  It receives server updates
> and other client requests for data.  When it receives a client update it 
> updates
> a couple tables in mysql.  When it receives a request from a server for data, 
> it
> goes to mysql gets all needed data, compiles it into the format requested and
> sends it down the wire.
>
> This daemon starts when my system starts up.  As of this morning it has been
> running non stop since Feb 28th (about 108 days).  Between then and now it has
> received over 35M server updates and over 1.8M client requests.  I think it 
> gets
> used a bit.
>
> So, to say that doing anything with PHP that takes longer then 30 seconds to
> complete will require you to use hacky and disgusting workarounds is false.
>
> I have no hacks nor disgusting workarounds in my scripts.  Combined the 
> scripts
> total about 200 lines, over half of which is either comments or vertical white
> space.
>
> It has been running pretty much non-stop since August 2007 with minimal
> maintenance needed.
>
> Jim Lucas
>

Hello,

Impressive stats and has me a bit intrigued!  Just out of curiosity,
does your daemon use a heavy amount of object orientation in it or is
it mostly procedural codebase?


Regards

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



Re: [PHP] Performance gain when not using prepared statements?

2011-06-17 Thread Eric Butera
On Fri, Jun 17, 2011 at 4:55 AM, Vitalii Demianets
 wrote:
> On Friday 17 June 2011 04:50:00 Daevid Vincent wrote:
>> > I've seen too many people over the years try and rally against common
>> > sense practices like using prepared statements for perhaps a marginal
>> > gain of performance on one page while their load averages are 0,0,0.
>>
>> Agreed. The ONLY time prepared statements are useful, is in a loop where
>> you're changing a few variables but within the same SQL statement. That is
>> a rare case for most people.
>>
>
> Not ONLY. I love prepared statements because with them I can store arbitrary
> strings in DB without need to worry about fancy escaping and SQL injection.
> And do it in DB-independent way.
> Think about all that extra escaping and performance gain of not using prepared
> statement will shrink a lot ) Don't have actual numbers though.
>
> --
> Vitalii
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You can implement caching at so many levels of the app that using a
prepared statement should be at the lower spectrum of your worries.
It is too easy to forget calling escape whether it be for a DB or
output to the browser as proven by all the various bug trackers and
hacked websites across the net.

Just to drive this point home, if you do a quick search on Secunia for
'SQL Injection' [1] you get 4,158 advisories.  Worth the risk?

http://secunia.com/advisories/search/?search=sql+injection

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



Re: [PHP] Doctrine madness!

2011-06-16 Thread Eric Butera
On Thu, Jun 16, 2011 at 9:50 PM, Daevid Vincent  wrote:
>
>
>> -Original Message-----
>> From: Eric Butera [mailto:eric.but...@gmail.com]
>> Sent: Thursday, June 16, 2011 5:53 PM
>> To: Daevid Vincent
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Doctrine madness!
>>
>> On Thu, Jun 16, 2011 at 7:32 PM, Daevid Vincent  wrote:
>> >
>> >
>> >> -Original Message-
>> >> From: Eric Butera [mailto:eric.but...@gmail.com]
>> >> Sent: Thursday, June 16, 2011 2:58 PM
>> >> To: Daevid Vincent
>> >> Cc: php-general@lists.php.net
>> >> Subject: Re: [PHP] Doctrine madness!
>> >>
>> >> On Thu, Jun 16, 2011 at 5:37 PM, Daevid Vincent 
>> wrote:
>> >> >> -Original Message-
>> >> >> From: Nathan Nobbe [mailto:quickshif...@gmail.com]
>> >> >> Sent: Thursday, June 16, 2011 9:51 AM
>> >> >> To: php-general@lists.php.net
>> >> >> Subject: [PHP] Doctrine madness!
>> >> >>
>> >> >> Hi gang,
>> >> >>
>> >> >> If anyone out there has some experience w/ Doctrine now would be a
>> great
>> >> >> time to share it!
>> >> >
>> >> > Yeah, I've used Doctrine as part of Symfony. Both suck balls and are a
>> >> perfect example of why you should NEVER use frameworks. Lesson learned
>> the
>> >> hard way. Re-write with your own MySQL wrappers and for the love of God
>> and
>> >> all that is holy do NOT make it an ORM wrapper.
>> >> >
>> >> > KTHXBYE.
>> >> >
>> >>
>> >> I do believe that was the most eloquent and enlightened email that has
>> >> ever graced my inbox.  Thank you for taking the time to edify us with
>> >> that pithy reply.
>> >
>> > Glad I could be of service. There was no point in elaborating more on
>> either Doctrine or Symfony any further.
>> >
>> > Sometimes, like that guy that fell down the canyon, you have to cut your
>> own arm off with a swiss army knife to save your life. In this case, get rid
>> of Doctrine or any other ORM, despite the painful operation, and save your
>> project from a slow and agonizing death.
>> >
>> > ORM's and "ActiveRecord" style wrappers, while sounding sexy -- like the
>> "babe" on the other end of a 1-900 number -- usually turn out to be fat and
>> bloated. All that "magic" comes at a price. This is why Ruby on Rails has
>> started to fall out of favor with ANY big shop and you are hearing less and
>> less about it. It's cute and seems magnificent at first, but quickly starts
>> to show its limitations and short-comings when you REALLY try to use it.
>> >
>> > :)
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>> I'm sorry but this is absolute rubbish.  I used to write my queries by
>> hand, but over time you start to realize that perhaps, maybe writing
>> out thousands of identical lines of code over hundreds of projects
>> might not be an efficient usage of time.
>
> I never said to do that. I said to write your own wrappers and your own 
> "framework" for YOUR needs. A one-size-fits all solution is never going to be 
> as clean or efficient as your own code. See previous rant and I'm sure there 
> are archives of my other rants on the failure that is ORM & Frameworks.
>
>> What is the more common question from clients: why is this so slow,
>> or, client asks why is this not finished yet?
>
> ...until the project gains traction and starts to get users and then it will 
> be, "why is this so slow?!"
>
>> I do like the half-hearted diatribe against ROR, which I will assume
>> is a wildcard, allow any language/framework combination to stand-in.
>
> Yes, frameworks as a whole suck.
>
> However, I will concede the one framework I do enjoy and find much more 
> useful is jQuery, if for no other reason than it handles all the minutia and 
> BS of browser incompatibilities and parsing the DOM in JS. It's fairly 
> lightweight and works very well for the most part. Even having said that, I 
> really only use jQuery on a need-to-use basis and not for everything JS 
> related. But once you have to include it in a page for some necessary reason, 
> you might as well continue to 

Re: [PHP] Doctrine madness!

2011-06-16 Thread Eric Butera
On Thu, Jun 16, 2011 at 7:32 PM, Daevid Vincent  wrote:
>
>
>> -Original Message-----
>> From: Eric Butera [mailto:eric.but...@gmail.com]
>> Sent: Thursday, June 16, 2011 2:58 PM
>> To: Daevid Vincent
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Doctrine madness!
>>
>> On Thu, Jun 16, 2011 at 5:37 PM, Daevid Vincent  wrote:
>> >> -Original Message-
>> >> From: Nathan Nobbe [mailto:quickshif...@gmail.com]
>> >> Sent: Thursday, June 16, 2011 9:51 AM
>> >> To: php-general@lists.php.net
>> >> Subject: [PHP] Doctrine madness!
>> >>
>> >> Hi gang,
>> >>
>> >> If anyone out there has some experience w/ Doctrine now would be a great
>> >> time to share it!
>> >
>> > Yeah, I've used Doctrine as part of Symfony. Both suck balls and are a
>> perfect example of why you should NEVER use frameworks. Lesson learned the
>> hard way. Re-write with your own MySQL wrappers and for the love of God and
>> all that is holy do NOT make it an ORM wrapper.
>> >
>> > KTHXBYE.
>> >
>>
>> I do believe that was the most eloquent and enlightened email that has
>> ever graced my inbox.  Thank you for taking the time to edify us with
>> that pithy reply.
>
> Glad I could be of service. There was no point in elaborating more on either 
> Doctrine or Symfony any further.
>
> Sometimes, like that guy that fell down the canyon, you have to cut your own 
> arm off with a swiss army knife to save your life. In this case, get rid of 
> Doctrine or any other ORM, despite the painful operation, and save your 
> project from a slow and agonizing death.
>
> ORM's and "ActiveRecord" style wrappers, while sounding sexy -- like the 
> "babe" on the other end of a 1-900 number -- usually turn out to be fat and 
> bloated. All that "magic" comes at a price. This is why Ruby on Rails has 
> started to fall out of favor with ANY big shop and you are hearing less and 
> less about it. It's cute and seems magnificent at first, but quickly starts 
> to show its limitations and short-comings when you REALLY try to use it.
>
> :)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I'm sorry but this is absolute rubbish.  I used to write my queries by
hand, but over time you start to realize that perhaps, maybe writing
out thousands of identical lines of code over hundreds of projects
might not be an efficient usage of time.  If you have performant
requirements, that is one thing and can easily be overcome with slight
deviations on a case by case basis.  Most of the time, contrary to
your position, things just need to work and be completed quickly.
What is the more common question from clients: why is this so slow,
or, client asks why is this not finished yet?

I do like the half-hearted diatribe against ROR, which I will assume
is a wildcard, allow any language/framework combination to stand-in.
The real take-away message here is that you're trying to paint
everything with the brush that you see the world in, while the reality
is that not everyone has your requirements.  Personally, I don't enjoy
trying to mess around with ill-conceived, backwards-compatible
adhering designs from 12 years ago.  I understand that growth is
organic and deal with it on a daily basis in my own projects.  Hence,
I use a framework and other tooling that allows me to complete jobs in
a tidy and orderly fashion.  If I need something a little more
cutting-edge I can always drop down lower on the stack to bypass PHP
with other techniques like caching or bypassing the framework
altogether.  To say that all frameworks are a complete waste of time
and will only (absolutely) end in failure is quite a disservice to
anyone who reads this list.

I've seen too many people over the years try and rally against common
sense practices like using prepared statements for perhaps a marginal
gain of performance on one page while their load averages are 0,0,0.
One archived post could be the cause of 50 hacked websites.  This is
not the position people - or, mentors, if you will - should be taking.
 Same with other tools that allow developers to crank out projects
orders faster.

This post isn't meant to be some vitriol inspired rant, but rather a
sincere wake-up.  Imagine the intended audience of php-general and ask
yourself if you're doing harm.  An example:  when I say harm, every
other framework I have seen from php (ok, ok, ZF makes you call
escape), ruby, python, and node all escape variables in
templates/views by default.  PHP is the only one that lets you echo
out XSS out of the box.  Of course, with diligen

Re: [PHP] Doctrine madness!

2011-06-16 Thread Eric Butera
On Thu, Jun 16, 2011 at 5:37 PM, Daevid Vincent  wrote:
>> -Original Message-
>> From: Nathan Nobbe [mailto:quickshif...@gmail.com]
>> Sent: Thursday, June 16, 2011 9:51 AM
>> To: php-general@lists.php.net
>> Subject: [PHP] Doctrine madness!
>>
>> Hi gang,
>>
>> If anyone out there has some experience w/ Doctrine now would be a great
>> time to share it!
>
> Yeah, I've used Doctrine as part of Symfony. Both suck balls and are a 
> perfect example of why you should NEVER use frameworks. Lesson learned the 
> hard way. Re-write with your own MySQL wrappers and for the love of God and 
> all that is holy do NOT make it an ORM wrapper.
>
> KTHXBYE.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I do believe that was the most eloquent and enlightened email that has
ever graced my inbox.  Thank you for taking the time to edify us with
that pithy reply.

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



Re: [PHP] Doctrine madness!

2011-06-16 Thread Eric Butera
On Thu, Jun 16, 2011 at 12:51 PM, Nathan Nobbe  wrote:
> Hi gang,
>
> If anyone out there has some experience w/ Doctrine now would be a great
> time to share it!
>
> So I'm writing a batch importer and noticed memory usage climbing during
> script execution.
>
> In the debugging effort I've isolated it down to a Doctrine issue.
>
> Here's what's going on, I instantiate a model object for the product table
> from my application
>
> $newRecord = new Product();
>
> at this point memory usage goes up noticeably.  I don't really care though
> because I figure I can delete it, but look at this madness I have going
> (which *fails* to free up the memory)
>
> $newRecord->clearRelated();
> $newRecord->free();
> unset($newRecord);
> gc_collect_cycles();
>
> after all of this memory consumption is still dramatically higher than prior
> to the first call creating the object above.  This I've verified through
> memory_get_usage().
>
> here's the output from the memory_get_usage() calls
>
> int(166461440) // before new Product()
> int(169345024) // directly after new Product()
> int(169345024) // after madness trying to free memory used by new Product()
>
> I've also tried an explicit call to the destructor of $newRecord, but that
> results in a fatal attempting to call an unknown method.
>
> Any help would be greatly appreciated as google hasn't been able to point me
> to the answer thus far.
>
> thx,
>
> -nathan
>

This might help

http://php.net/manual/en/features.gc.collecting-cycles.php

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



Re: [PHP] Best authentication system

2011-06-04 Thread Eric Butera
On Sat, Jun 4, 2011 at 2:44 PM, Adam Tong  wrote:
> Hi,
>
> I'm running a site for which I need an authentication system. I have
> already my own (that is too simplistic and not very secure).
> I want some advice here. I checked PEAR, but as there are several
> options there, I was not sure which one to choose. Here are my needs:
>
> - Some sections of the site cannot be accessed if the user does not
> have an account (at least login and password)
> - There are 2 type of users at this moment, depending on that type,
> the user can access some sections and not the others (the ones allowed
> for the other type). Maybe in the future there will be more types of
> users.
>
> Thank you
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Hello,

There is terminology in place for what you're trying describe.  First
take authentication, the ability to log into a system.  Second would
be authorization, the abilities a user has.  With these terms you can
do some further research on the subject.

For reference in a lot of projects for authentication I use
Zend_Auth[1] and for authorization I use Zend_Acl[2].  Hopefully
linking to them will not contribute to further confusion.

1. http://framework.zend.com/manual/en/zend.auth.html
2. http://framework.zend.com/manual/en/zend.acl.html

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



Re: [PHP] phpsadness

2011-06-03 Thread Eric Butera
On Fri, Jun 3, 2011 at 1:05 PM, Marc Guay  wrote:
> What's PHP?  I thought this was the
> top-posting-etiquette-discussion-and-simmering-race-war group.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I just wanted to do my part to add to the noise-to-signal ratio.
Thanks for assisting!

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



Re: [PHP] phpsadness

2011-06-03 Thread Eric Butera
On Fri, Jun 3, 2011 at 12:37 PM, Jasper Mulder  wrote:
>
>> Stuart Dallas wrote:
>>
>> [SNIP]
>>
>> And this is where we disagree. Everyone is entitled to an opinion, and
>> they're also entitled to express that opinion, whether through humour or
>> simple statement.
>
> Somehow in your response I taste that you don't like people, whose opinion
> is that not everybody has the right to express their opinion, expressing
> their opinion. Which is an annoying fact about most free speech defenders
> and liberals.
>
>> [SNIP]
>> I repeat that tedd did
>> not say anything about the religion, he simply referenced factual events.
>> [SNIP]
>
> Whilst you may have a point here, I still think that we should be cautious
> with saying what somebody else meant. After all, this is how misconceptions
> and rumours are spread every day.
>
> As a last, I must say that I liked this thread better when it considered PHP
> only; though being aware that this post has only extended the list by one.
> Let us get over it and get back to discussing what we all *do* like: PHP.
>
> Best regards,
> Jasper Mulder
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

In the same vein it is a bit presumptuous to assume we all like PHP. :)

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



Re: [PHP] Announcing New PHP Extension: System Detonation Library (was: phpsadness)

2011-06-03 Thread Eric Butera
On Fri, Jun 3, 2011 at 11:56 AM, Daniel Brown  wrote:
>    First of all, a happy Friday to all here.  Hopefully some of you
> will be able to pass this on to your boss and get sent home early.
>
>    Second, as dreamed up in the previous thread, I've decided to take
> a few moments this morning to build and release a new PHP extension,
> which provides a single function: detonate().
>
>    Third, you can read about it and download it here:
> http://links.parasane.net/29nh
>
>    That's all, folks.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Why do you insist on invading my privacy by making me use your url
shortening service? :)

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



Re: [PHP] How can a UTF-8 string can be converted to an array of Bytes?

2011-05-25 Thread Eric Butera
On Wed, May 25, 2011 at 8:15 AM, Eli Orr (Office)  wrote:
> Hi,
>
> Since a UTF-8 is a multi-bytes mechanism I get for 2 or 3 bytes  UTF-8
> encoded character a single character
>
> How can it be break into the REAL bytes array that represent the UTF-8
> string
>  and how  can we reassembled the bytes array  back to UTF-8?
>
> --
> Best Regards,
>
> *Eli Orr*
> CTO & Founder
> *LogoDial Ltd.*
>
> __
>

You can use mb_substr [1] with a UTF-8 encoding to get the single characters.

http://us.php.net/mb_substr

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



Re: [PHP] observer pattern

2011-05-23 Thread Eric Butera
On Mon, May 23, 2011 at 5:14 PM, Daevid Vincent  wrote:
>> -Original Message-
>> From: Eric Butera [mailto:eric.but...@gmail.com]
>> Sent: Friday, May 20, 2011 2:25 PM
>> To: PHP
>> Subject: Re: [PHP] observer pattern
>>
>> [whoops didn't hit reply-all]
>>
>> On Wed, May 18, 2011 at 5:18 AM, Ken Guest  wrote:
>> > Lo,
>> >
>> > so, I'm wondering - how many of you use the observer pattern in php;
>> > and if so, do you implement it 'standalone' or with the spl classes?
>> > Is there any particular advantage to doing it "your way"; whichever
>> > your way is?
>> >
>> > Ken
>> >
>> > --
>> > http://blogs.linux.ie/kenguest/
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>> I use it quite a bit over the various projects I maintain.  It allows
>> subjects to trigger events that observers can process if they're
>> interested, or better yet, completely ignore.  This allows
>> standardized code bases to create nice hooks that allow extensibility
>> without needing to place one-off code inside the main project.
>>
>> A quick example might be on saving a record in your code, it triggers
>> an event, then an observer in a custom site watches for said event and
>> injects/updates a search entry in Lucene.  This way one site can have
>> a custom search engine that another site might not need.
>>
>> I started off with the concepts I found in
>> http://examples.stubbles.net/docroot/events/ but created my own
>> because I wanted something stand-alone.
>
> Well, you (or in this case, *I*) learn something new every day.
>
> I had no idea PHP could do observers. How very "Java" (and neat!)
> Granted, it is just a design pattern, but to have the SplObserver stuff built 
> in is pretty cool.
> What version of PHP is this available from? The web page doesn't say.
>
> http://www.labelmedia.co.uk/blog/posts/php-design-patterns-observer-pattern.html
> http://cormacscode.wordpress.com/2010/10/12/practical-example-php-implementation-of-the-observer-pattern/
> http://www.php.net/manual/en/book.spl.php
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Hi Daevid,

According to http://us3.php.net/manual/en/splobserver.update.php, (PHP
5 >= 5.1.0)

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



Re: [PHP] observer pattern

2011-05-20 Thread Eric Butera
[whoops didn't hit reply-all]

On Wed, May 18, 2011 at 5:18 AM, Ken Guest  wrote:
> Lo,
>
> so, I'm wondering - how many of you use the observer pattern in php;
> and if so, do you implement it 'standalone' or with the spl classes?
> Is there any particular advantage to doing it "your way"; whichever
> your way is?
>
> Ken
>
> --
> http://blogs.linux.ie/kenguest/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I use it quite a bit over the various projects I maintain.  It allows
subjects to trigger events that observers can process if they're
interested, or better yet, completely ignore.  This allows
standardized code bases to create nice hooks that allow extensibility
without needing to place one-off code inside the main project.

A quick example might be on saving a record in your code, it triggers
an event, then an observer in a custom site watches for said event and
injects/updates a search entry in Lucene.  This way one site can have
a custom search engine that another site might not need.

I started off with the concepts I found in
http://examples.stubbles.net/docroot/events/ but created my own
because I wanted something stand-alone.

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



Re: [PHP] New to list and to PHP

2011-02-20 Thread Eric Butera
On Sun, Feb 20, 2011 at 8:38 PM, tolga  wrote:
> 21.02.2011 03:21, Tamara Temple yazmış:
>>
>> On Feb 20, 2011, at 5:51 PM, tolga wrote:
>>
>>> 21.02.2011 01:41, Richard Quadling yazmış:

 On 20 February 2011 23:34, Richard Quadling  wrote:
>
> On 18 February 2011 19:03, Pete Woodhead
>  wrote:
>>
>> Hi I'm Pete Woodhead.  I'm new to the list and to PHP.  To be honest I
>> very
>> new to code writing.
>> Thought this would be a good way to learn good habits as well as good
>> code
>> writing.
>> Looking forward to learning and participating.
>>
> Assume that all the data you get from the user is out to get you. It
> probably isn't. Most of the time. But when it does, it'll be your
> fault. Unless you've left the company by then.
>
> Also, poka-yoke is a great concept to learn about (thanks to a great
> article in php|Architect all the way back when).
>
> Richard.
>
> --
> Richard Quadling
> Twitter : EE : Zend
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>
 http://www.phparch.com/magazine/2006-2/february/ in case anyone was
 wondering.

>>> i'm interested in php about 3 maybe 4 years but i still couldnt get the
>>> logic of classes. it makes no sense to me. i couldnt understand whats about
>>> classes good at or how to use or write it. and i can say that " is 'class'
>>> really necessery? "
>>
>> a class is construct of Object Oriented PHP. If you don't understand
>> object oriented programming, you'll likely not understand the use of object
>> and classes in PHP, either. There are good reasons to use object oriented
>> principles in PHP and other langages, and good reasons to use procedural
>> principles in PHP as well. Learning when to use either is important.
>> Learning how to use classes someone else implements is also important to
>> keep from re-re-re-re-re-reinventing the wheel.
>>
>>
> thanks. are there any high detailed explanation of classes in php? except
> for php.net, cuz i didnt understand anything from there about classes.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Pretty say to see a lmgtfy response, so I'll try and provide something
slightly more worthwhile.  First off, what is so bad about the php.net
documentation?  If it is over your head, then I'd say get yourself
some books and study fundamentals.  Granted, you don't need to buy
anything as searches will yield the proper results--of course this is
much more difficult if you don't know the terms.  I was confused at
first too, but I persisted and learned a few tricks.  I started off by
studying open source projects & reading the code/searching for the
method names it used.  Look around on Github, it is all there for your
consumption!  Just FYI, my favorite book was Head First Deign
Patterns.

I think the best part about coding is that there is no "right way."
There are millions of solutions to these problems whether they be
classical, prototypal, functional, or whatever. :)  Either way, good
luck!

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



Re: [PHP] SQL insert () values (),(),(); how to get auto_increments properly?

2010-02-14 Thread Eric Lee
On Sat, Feb 13, 2010 at 7:41 PM, Jochem Maas  wrote:

> Op 2/13/10 11:36 AM, Eric Lee schreef:
> >
> >
> > On Sat, Feb 13, 2010 at 6:55 PM, Jochem Maas  > <mailto:joc...@iamjochem.com>> wrote:
> >
> > Op 2/13/10 10:08 AM, Lester Caine schreef:
> > > Rene Veerman wrote:
> > >> Hi.
> > >>
> > >> I'm looking for the most efficient way to insert several records
> and
> > >> retrieve the auto_increment values for the inserted rows, while
> > >> avoiding crippling concurrency problems caused by multiple php
> > threads
> > >> doing this on the same table at potentially the same time.
> > >
> > >> Any clues are greatly appreciated..
> > >> I'm looking for the most sql server independent way to do this.
> > >
> > > Rene
> > > The 'correct' way of doing this is to use a 'sequence' which is
> > > something introduced in newer versions of the SQL standard.
> > > Firebird(Interbase) has had 'generators' since the early days (20+
> > > years) and these provide a unique number which can then be
> > inserted into
> > > the table.
> > >
> > > ADOdb emulates sequences in MySQL by creating a separate table for
> the
> > > insert value, so you can get the next value and work with it,
> without
> > > any worries. The only 'problem' is in situations were an insert is
> > > rolled back, a number is lost, but that is ACTUALLY the correct
> > result,
> > > since there is no way of knowing that a previous insert WILL
> > commit when
> > > several people are adding records in parallel.
> >
> > this is all true and correct ...
> >
> > but that doesn't answer the problem. how do you get the IDs of all
> > the records
> > that we're actually inserted in a multi-insert statement, even if
> > you generate the
> > IDs beforehand you have to check them to see if any one of the set
> > INSERT VALUEs failed.
> >
> > @Rene:
> >
> > I don't think there is a really simple way of doing this in a RDBMS
> > agnostic
> > way, each RDBMS has it's own implementation - although many are
> > alike ... and MySQL is
> > pretty much the odd one out in that respect.
> >
> > it might require a reevaluation of the problem, to either determine
> > that inserting
> > several records at once is not actually important in terms of
> > performance (this would depend
> > on how critical the speed is to you and exactly how many records
> > you're likely to be inserting
> > in a given run) and whether you can rework the logic to do away with
> > the requirement to
> > get at the id's of the newly inserted records ... possibly by
> > indentifying a unique
> > indentifier in the data that you already have.
> >
> > one way to get round the issue might be to use a generated GUID and
> > have an extra field which
> > you populate with that value for all records inserted with a single
> > query, as such it could
> > function as kind of transaction indentifier which you could use to
> > retrieve the newly
> > inserted id's with one extra query:
> >
> >$sql = "SELECT id FROM foo WHERE insert_id = '{$insertGUID}'";
> >
> > ... just an idea.
> >
> > >
> >
> >
> >
> > Hi
> >
> > I would like to learn more correct  way from both of you.
> > May I ask what is a sequences ?
>
> it an RDBMS feature that offers a race-condition free method of
> retrieving a new unique identifier for a record you wish to enter,
> the firebird RDBMS that Lester mentions refers to this as 'generators'.
>
> to learn more I would suggest STW:
>
>http://lmgtfy.com/?q=sql+sequence
>
>
 Jochem


Thanks,

Regards,
Eric

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


Re: [PHP] SQL insert () values (),(),(); how to get auto_increments properly?

2010-02-13 Thread Eric Lee
On Sat, Feb 13, 2010 at 6:55 PM, Jochem Maas  wrote:

> Op 2/13/10 10:08 AM, Lester Caine schreef:
> > Rene Veerman wrote:
> >> Hi.
> >>
> >> I'm looking for the most efficient way to insert several records and
> >> retrieve the auto_increment values for the inserted rows, while
> >> avoiding crippling concurrency problems caused by multiple php threads
> >> doing this on the same table at potentially the same time.
> >
> >> Any clues are greatly appreciated..
> >> I'm looking for the most sql server independent way to do this.
> >
> > Rene
> > The 'correct' way of doing this is to use a 'sequence' which is
> > something introduced in newer versions of the SQL standard.
> > Firebird(Interbase) has had 'generators' since the early days (20+
> > years) and these provide a unique number which can then be inserted into
> > the table.
> >
> > ADOdb emulates sequences in MySQL by creating a separate table for the
> > insert value, so you can get the next value and work with it, without
> > any worries. The only 'problem' is in situations were an insert is
> > rolled back, a number is lost, but that is ACTUALLY the correct result,
> > since there is no way of knowing that a previous insert WILL commit when
> > several people are adding records in parallel.
>
> this is all true and correct ...
>
> but that doesn't answer the problem. how do you get the IDs of all the
> records
> that we're actually inserted in a multi-insert statement, even if you
> generate the
> IDs beforehand you have to check them to see if any one of the set INSERT
> VALUEs failed.
>
> @Rene:
>
> I don't think there is a really simple way of doing this in a RDBMS
> agnostic
> way, each RDBMS has it's own implementation - although many are alike ...
> and MySQL is
> pretty much the odd one out in that respect.
>
> it might require a reevaluation of the problem, to either determine that
> inserting
> several records at once is not actually important in terms of performance
> (this would depend
> on how critical the speed is to you and exactly how many records you're
> likely to be inserting
> in a given run) and whether you can rework the logic to do away with the
> requirement to
> get at the id's of the newly inserted records ... possibly by indentifying
> a unique
> indentifier in the data that you already have.
>
> one way to get round the issue might be to use a generated GUID and have an
> extra field which
> you populate with that value for all records inserted with a single query,
> as such it could
> function as kind of transaction indentifier which you could use to retrieve
> the newly
> inserted id's with one extra query:
>
>$sql = "SELECT id FROM foo WHERE insert_id = '{$insertGUID}'";
>
> ... just an idea.
>
> >
>
>
>
Hi

I would like to learn more correct  way from both of you.
May I ask what is a sequences ?


Thanks !


Regards,
Eric

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


Re: [PHP] SQL insert () values (),(),(); how to get auto_increments properly?

2010-02-13 Thread Eric Lee
On Sat, Feb 13, 2010 at 2:07 PM, Rene Veerman  wrote:

> Hi.
>
> I'm looking for the most efficient way to insert several records and
> retrieve the auto_increment values for the inserted rows, while
> avoiding crippling concurrency problems caused by multiple php threads
> doing this on the same table at potentially the same time.
>
> I'm using mysql atm, so i thought "stored procedures!"..
> But alas, mysql docs are very basic.
>
> I got the gist of how to setup a stored proc, but how to retrieve a
> list of auto_increment ids still eludes me; last_insert_id() only
> returns for the last row i believe.
> So building an INSERT (...) VALUES (...),(...) at the php end, is
> probably not the way to go then.
>
> But the mysql docs don't show how to pass an array to a stored
> procedure, so i can't just have the stored proc loop over an array,
> insert per row, retrieve last_insert_id() into temp table, and return
> the temp table contents for a list of auto_increment ids for inserted
> rows.
>
> Any clues are greatly appreciated..
> I'm looking for the most sql server independent way to do this.
>
>
Rene

 I have not been worked with mysql multi-insert before.
But just did a simple test on my mysql 5.0 copy.

I assume that you are using MyISAM table and will lock its read, writel
when inserting data.

When multi-insert was done, and did a select last_insert_id(). I saw that
only
the first inserted id was returned. Please take a look the following steps:


mysql> select * from temp;
Empty set (0.00 sec)

mysql> insert into temp (firstname, price) values ('dd', 10), ('cc', 3),
('bb', 99);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select last_insert_id();
+--+
| last_insert_id() |
+--+
|1 |
+--+
1 row in set (0.00 sec)

mysql> insert into temp (firstname, price) values ('dd', 10), ('cc', 3),
('bb', 99);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select last_insert_id();
+--+
| last_insert_id() |
+--+
|4 |
+--+
1 row in set (0.00 sec)


So, let's say three records was inserted, and the first inserted id was 1.
You get id from 1 to 3.

! This will not work on transaction-based insert !

Just a thought and tested on mysql but not on php.



Regards,
Eric

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


Re: [PHP] How to secure this

2010-02-12 Thread Eric Lee
On Sat, Feb 13, 2010 at 7:33 AM, Ryan Sun  wrote:

> In that case, referer is for authentication, and id is for authorization, I
> think
>
> On Fri, Feb 12, 2010 at 6:23 PM, Ashley Sheridan
> wrote:
>
> >  On Fri, 2010-02-12 at 18:25 -0500, Ryan Sun wrote:
> >
> > authenticate by remote domain name or remote ip
> >
> > $_SERVER['HTTP_REFERER']
> >
> > then your clients will not have to put their username/password in clear
> texthttp://www.mydomain.com?h=300&w=250
> > and you will just check if you have their domain on your list
> >
> > I'm not sure if there is better one but
> > " 'HTTP_REFERER'
> > The address of the page (if any) which referred the user agent to
> > the current page. This is set by the user agent. Not all user agents
> > will set this, and some provide the ability to modify HTTP_REFERER as
> > a feature. In short, it cannot really be trusted. "
> >
> >
> > On Fri, Feb 12, 2010 at 4:26 PM, Robert Cummings 
> wrote:
> > > Ashley Sheridan wrote:
> > >>
> > >> On Fri, 2010-02-12 at 16:12 -0500, Robert Cummings wrote:
> > >>
> > >>> John Allsopp wrote:
> > >>>>
> > >>>> Hi everyone
> > >>>>
> > >>>> There may be blinding bits of total ignorance in this so don't
> ignore
> > >>>> the obvious.
> > >>>>
> > >>>> This is a security question, but a sentence of background: I'm
> writing
> > >>>> software for a mapping/location website and I want to be able to
> provide
> > >>>> something others can plug into their website that would display
> their map.
> > >>>>
> > >>>> So I'm providing a URL like
> > >>>> http://www.mydomain.com?h=300&w=250&username=name&password=password
> > >>>>
> > >>>> The idea is they can define their own height and width and it plugs
> in
> > >>>> as an iframe.
> > >>>>
> > >>>> That takes the username and password and throws it over web services
> to
> > >>>> get back the data from which we can create the map.
> > >>>>
> > >>>> My question (and it might be the wrong question) is how can I not
> give
> > >>>> away the password to all and sundry yet still provide a
> self-contained URL?
>


How about RESTful like checking ?
It is much like what Rob said already.
but join all params by order and md5 it altogether


Regards,
Eric,


> > >>>
> > >>> MD5() (or SHA()) hash the information and supply that along with the
> > >>> settings. Then you know it was generated by your site. So you can do
> the
> > >>> following:
> > >>>
> > >>>  > >>>
> > >>> $height = 300;
> > >>> $width = 250;
> > >>> $username = 'username';
> > >>> $key = md5( "SECRET_SALT-$heigh-$width-$username" );
> > >>>
> > >>> $url =
> > >>> "
> http://www.mydomain.com?h=$height&w=$width&username=$username&key=$key";;
> > >>>
> > >>> ?>
> > >>>
> > >>> Then when you get this URL via the iframe, you re-compute the
> expected
> > >>> key and then compare it against the given key. Since only you know
> the
> > >>> SECRET_SALT value then nobody should be able to forge the key.
> > >>>
> > >>> Cheers,
> > >>> Rob.
> > >>> --
> > >>> http://www.interjinn.com
> > >>> Application and Templating Framework for PHP
> > >>>
> > >>
> > >>
> > >> What about requiring them to sign in the first time to use your
> service,
> > >> and then give them a unique id which i tied to their details. You
> could
> > >> then get them to pass across this id in the url. You could link their
> > >> account maybe to some sorts of limits with regards to what they can
> > >> access maybe?
> > >
> > > Presumably they ARE logged in when you create this URL for them...
> otherwise
> > > someone else could generate it :)
> > >
> > > 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
> > >
> > >
> >
> >
> >
> > I think Google does both the referrer check coupled with an id passed in
> > the URL. At least, this is what it did the last time I embedded one of
> their
> > maps.
> >
> >
> >   Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>


RE: [PHP] RE: SOAP connect error

2010-02-11 Thread Eric Lommatsch

>Are you using wsdl? If so, does the WSDL file contain the information that
the port to use for the requests is on port 8080?
>
>--
>-
>Richard Quadling
>"Standing on the shoulders of some very clever giants!"
>EE : http://www.experts-exchange.com/M_248814.html
>EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
>ZOPA : http://uk.zopa.com/member/RQuadling

First, I am sorry for not getting back to this yesterday. I had some other
things come up.

As far as I know this website is using WSDL. I know that one of the early
issues I ran into in trying to get this to work was not having the wsdl.php
file in the path.

That having been said are you talking about the wsdl file on the server that
is providing the service or are you talking about the wsdl file on the system
hosting the webpage. 

I can get everything to work correctly when I am working from our internal
development server. But when I attempt to put the file on the hosted site our
clients would ultimately be using I am getting the connect error. 

I have compared the wsdl.php files on these two servers and neither of them
have specific information about the port in them.

Here is the code that I am using to connect to the webservice:

$webservices_uri =
"http://xx.xx.xx.xx:8080/jasperserver/services/repository";;

Here is the code where I am trying to connect:

function ws_checkUsername($username, $password)
{
$connection_params = array("user" => $username, "pass" =>
$password);
$info = new SOAP_client($GLOBALS["webservices_uri"], false,
false, $connection_params);

$op_xml = "".
"";

$params = array("request" => $op_xml );
$response = $info->call("list",$params,array('namespace' =>
$GLOBALS["namespace"]));

return $response;
}

This is working when I use the IP address of the server behind the firewall,
but when I try to use the address that is open through the firewall it is not
connecting. I can connect to the external IP address by entering it into the
browser and it does ask for the username and password.

Thank you
 
Eric H. Lommatsch
Programmer
360 Business 
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927
 
er...@360b.com

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



Re: [PHP] syntax error in class

2010-02-10 Thread Eric Lee
2010/2/11 Jim Lucas 

> Dasn wrote:
>
>> I got the syntax error. Why?
>>
>
>
only constant literal is allowed.
You can think that it is static complie but not on runtime .


Regards,
Eric,




> Read the first paragraph on the following page.
>
> http://us3.php.net/manual/en/language.oop5.properties.php
>
> [quote]
> ...  This declaration may include an initialization, but this
> initialization must be a constant value--that is, it must be able to be
> evaluated at compile time and must not depend on run-time information in
> order to be evaluated.
> [/quote]
>
> Basically, anything that requires the concatenation of string parts or
> usage of variables is not allowed.
>
> --
> Jim Lucas
>
>   "Some men are born to greatness, some achieve greatness,
>   and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
>by William Shakespeare
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] RE: SOAP connect error

2010-02-09 Thread Eric Lommatsch
>-Original Message-
>From: Shawn McKenzie [mailto:nos...@mckenzies.net] 
>Sent: Tuesday, February 09, 2010 3:07 PM
>To: Eric Lommatsch
>Cc: php-general@lists.php.net
>Subject: Re: SOAP connect error
>
>Eric Lommatsch wrote:
>> Hello,
>>  
>> I am working with the SOAP package of PHP and I am trying make a 
>> connection from a hosted website to a server in our office.
>>  
>> I can get to the server perfectly fine from within our office, but I 
>> cannot connect from the eternal site.
>>  
>> I have checked and I am certain that the firewall for the server is open.
>> When I attempt to use the login page that I have created for the 
>> website I am getting the following error message:
>>  
>> Connect Error to XX.XX.XX.XXX:8080
>>  
>> Where XX.XX.XX.XXX mask the actual ip address of the server. I have 
>> tried to interogate all the values that soap_fault documents that it 
>> can return and the only information I have been able to find beside 
>> the above message, which is the $errorstring, is that my $faultcode =
"HTTP".
>>  
>> The information that I am getting is very cryptic. if I include our ip 
>> address when I search I get no results. If I put in connect error 
>> :8080 I get millions of meaningless results.
>>  
>> Can someone please help to figure out how to get more meaningful 
>> information from soap_fault for this problem so that I can figure out how
to fix it.
>>  
>> Thank you
>>  
>> Eric H. Lommatsch
>> Programmer
>> 360 Business
>> 2087 South Grant Street
>> Denver, CO 80210
>> Tel 303-777-8939 Ext 23
>> Fax 888-282-9927
>>  
>> er...@360b.com
>>  
>> 
>
>If you go home or to Starbucks can you get to http://XX.XX.XX.XXX:8080 ?
> If not, then the external server can't either.  It could be a network
firewall/proxy sever in your office, or any number of things.
>
>--
>Thanks!
>-Shawn
>http://www.spidean.com


I have connected to a clients computer that is remote from our office and I
am able to get to http://XX.XX.XX.XXX:8080. I probably should have mentioned
that when I try to get the webservice outside of the PHP site I am developing
I can get into that just fine. It is just when I try to use the PHP SOAP
client to access the webservice that I am getting the issue.


Thank you
 
Eric H. Lommatsch
Programmer
360 Business 
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927
 
er...@360b.com

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



[PHP] SOAP connect error

2010-02-09 Thread Eric Lommatsch
Hello,
 
I am working with the SOAP package of PHP and I am trying make a connection
from a hosted website to a server in our office. 
 
I can get to the server perfectly fine from within our office, but I cannot
connect from the eternal site.
 
I have checked and I am certain that the firewall for the server is open.
When I attempt to use the login page that I have created for the website I am
getting the following error message:
 
Connect Error to XX.XX.XX.XXX:8080
 
Where XX.XX.XX.XXX mask the actual ip address of the server. I have tried to
interogate all the values that soap_fault documents that it can return and
the only information I have been able to find beside the above message, which
is the $errorstring, is that my $faultcode = "HTTP".
 
The information that I am getting is very cryptic. if I include our ip
address when I search I get no results. If I put in connect error :8080 I get
millions of meaningless results.
 
Can someone please help to figure out how to get more meaningful information
from soap_fault for this problem so that I can figure out how to fix it.
 
Thank you
 
Eric H. Lommatsch
Programmer
360 Business 
2087 South Grant Street
Denver, CO 80210
Tel 303-777-8939 Ext 23
Fax 888-282-9927
 
er...@360b.com
 


Re: [PHP] stream_select() not working on regular files?

2010-02-03 Thread Eric Lee
On Thu, Feb 4, 2010 at 9:20 AM, Dennis J.  wrote:

> On 02/04/2010 02:03 AM, Ashley Sheridan wrote:
>
>> On Thu, 2010-02-04 at 01:41 +0100, Dennis J. wrote:
>>
>>> Hi,
>>> I'm trying to implement something similar to"tail -f"  in php but I'm
>>> running into a problem.
>>> The issue occurs when I've reached the end of the file. From here I
>>> basically have to loop until new lines get appended to the file but I
>>> would
>>> like to respond immediately when then happens. There are three options
>>> that
>>> I can see:
>>>
>>> 1. Busy-loop
>>> pro: I can process new lines immediately
>>> contra: Excessivley CPU intensive =>  not a real option
>>>
>>> 2. add a sleep(1) to the loop
>>> pro: No longer kills the CPU
>>> contra: I might get a 1 second delay until I can process new lines
>>>
>>> 3. stream_select(array($fh),null,null,1)
>>> pro: sleeps for one second but returns earlier if new data arrives
>>> contra: doesn't seem to work in files?
>>>
>>> Method 3 is the preferable one but doesn't seem to work:
>>>
>>> $fh = fopen("testfile","r");
>>> $r = array($fh);
>>> while( ($n = stream_select($r,$w=null,$e=null,1)) == 1 ) {
>>>  echo fgets($fh);
>>> }
>>>
>>> This program will loop forever because stream_select() will always return
>>> 1
>>> even at the end of the file.
>>>
>>> Is there any other way to accomplish this?
>>>
>>> Regards,
>>>Dennis
>>>
>>>
>> I thought that once it reached the end of the file, it will return a 0
>> indicating no new activity?
>>
>
> That's what I thought too but apparently that is not the case.
>
>
>  Although, surely you want the loop to continue forever, so that new
>> entries added to the end of the file are shown as soon as they appear.
>>
>
> Yes the loop is supposed to continue forever in the final version. In fact
> I what I'm trying to get at is a "tail -F" which means I will repeatedly
> reopen the file to check if it has been replaced by a new one. I just
> simplified the problem above to get rid of all the additional complexity and
> concentrate on the specific problem I have.
>
> My expectation was that once the end of the file is reached (i.e. fgets()
> has consumed all lines) stream_select() should wait for 1 second (in the
> above example) and if nothing happens with the file in that second it should
> return 0. But that doesn't happen.
>
>
>
Dennis

I have just been bulit a simple test script.
It works for me with a feof call if the stream was at end of file.
But I'am not sure that is that what you want !

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


Re: [PHP] File Upload

2010-01-30 Thread Eric Lee
On Sat, Jan 30, 2010 at 7:27 PM, Ali Reza Sajedi wrote:

> Hello,
>
> When uploading a file the variable $_FILES['userfile']['tmp_name'] is not
> set and when debugging I get the following error although /tmp folder exists
> and the permissions are set to 777:
>
> $_FILES['userfile']['error'] = 6
>
> which says
>
> UPLOAD_ERR_NO_TMP_DIR
> Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP
> 5.0.3.
>
> Has anyone encountered such a problem or has a clue as to what the cause
> could be?
>
>
It might be the upload_tmp_dir no pointing to the right dir !
What is the current of it ?



Regards,
Eric,



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


Re: [PHP] Re: how do I use php://memory?

2010-01-29 Thread Eric Lee
On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie wrote:

> Mari Masuda wrote:
>
> > Has anyone ever successfully used php://memory before?  If so, what
> > can I do to use it in my code?  Thank you.
>
> No, but I was intrigued to try it, so I tested this:
>
> $text = 'Some text.';
> file_put_contents('php://memory', $text);
> echo file_get_contents('php://memory');
>
> And it returned nothing.  The docs suck on this and it apparently
> doesn't work.  I see others use it with fopen(), but there is no mention
> of which file functions it works with and which it doesn't.
>
>

Shawn

I did a sample test from the manual with fopen like this,




console output

F:\wc\trunk>php -f m.php
line 1



Regards,
Eric,

--
> 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] exception throw from __autoload could not be catched on php 5.3.1

2010-01-28 Thread Eric Lee
Hi all and thanks for Ryan,


I apologize ! !
I have missed out the small class_exists call before it.


Thanks.


Regards,
Eric,

2010/1/29 Ryan 

> 于 2010-1-29 13:19, Ashley Sheridan 写道:
> > On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote:
> >
> >
> >> Hi php-dev pros,
> >>
> >> I got an issue about catching exception throw from __autoload on php
> 5.3.1.
> >>
> >> The manual state that exception throw from __autoload could be catched
> with
> >> try.. catch statement same as the normal flow.
> >>
> >> But I'can archive that even I have copied the same sample code from the
> >> manual.
> >>
> >> Here are the code segment.
> >>
> >> [[[
> >> function __autoload($name) {
> >> echo "Want to load $name.\n";
> >> throw new Exception("Unable to load $name.");
> >> }
> >>
> >> try {
> >> $obj = new NonLoadableClass();
> >> } catch (Exception $e) {
> >> echo $e->getMessage(), "\n";
> >> }
> >>
> >> ]]]
> >>
> >> Are there anyone experienced this or not ?
> >>
> >> Thanks in advance !
> >>
> >> Regards,
> >> Eric,
> >>
> >
> > Sorry, ignore that, I see you're running 5.3.1, which should be fine for
> > running the example. I do notice that you've got [[[ and ]]] in-place of
> > , was that intentional?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> >
> Do you have any other autoload implamentaions? try testing that code
> segment in a single php file and dump phpinfo() to make sure you are on
> php 5.3.1
>


Re: [PHP] exception throw from __autoload could not be catched on php 5.3.1

2010-01-28 Thread Eric Lee
On Fri, Jan 29, 2010 at 1:19 PM, Ashley Sheridan
wrote:

>  On Fri, 2010-01-29 at 13:02 +0800, Eric Lee wrote:
>
> Hi php-dev pros,
>
> I got an issue about catching exception throw from __autoload on php 5.3.1.
>
> The manual state that exception throw from __autoload could be catched with
> try.. catch statement same as the normal flow.
>
> But I'can archive that even I have copied the same sample code from the
> manual.
>
> Here are the code segment.
>
> [[[
> function __autoload($name) {
> echo "Want to load $name.\n";
> throw new Exception("Unable to load $name.");
> }
>
> try {
> $obj = new NonLoadableClass();
> } catch (Exception $e) {
> echo $e->getMessage(), "\n";
> }
>
> ]]]
>
> Are there anyone experienced this or not ?
>
> Thanks in advance !
>
> Regards,
> Eric,
>
>
> Sorry, ignore that, I see you're running 5.3.1, which should be fine for
> running the example. I do notice that you've got [[[ and ]]] in-place of
> , was that intentional?
>

Sorry for that !   I'am too lazy !!
And that's just for easy looking the code.

I actually use this,

getMessage(), "\n";
}



?>


Regards,
Eric,


>
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


[PHP] exception throw from __autoload could not be catched on php 5.3.1

2010-01-28 Thread Eric Lee
Hi php-dev pros,

I got an issue about catching exception throw from __autoload on php 5.3.1.

The manual state that exception throw from __autoload could be catched with
try.. catch statement same as the normal flow.

But I'can archive that even I have copied the same sample code from the
manual.

Here are the code segment.

[[[
function __autoload($name) {
echo "Want to load $name.\n";
throw new Exception("Unable to load $name.");
}

try {
$obj = new NonLoadableClass();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}

]]]

Are there anyone experienced this or not ?

Thanks in advance !

Regards,
Eric,


Re: [PHP] Pointers For Newbies, Reminders For Oldies

2010-01-27 Thread Eric Lee
On Wed, Jan 27, 2010 at 11:44 PM, Ashley Sheridan
wrote:

> On Wed, 2010-01-27 at 10:42 -0500, Paul M Foster wrote:
>
> > "... should be obvious - but are often overlooked - points within coding
> > practice that can cause the programmer to develop bad habits and bad
> > code." - Dan Brown
> >
> > Tip #1:
> >
> > Don't use count() in loops unless there are very few items to count and
> > performance doesn't matter, or the number will vary over the loop. That
> > is, don't do this:
> >
> > for ($i = 0; $i < count($items); $i++)
> >
> > Instead, do this:
> >
> > $number = count($items);
> > for ($i = 0; $i < $number; $i++)
> >
> > Reason: when you use the count() call at the top of the loop, it will
> > re-evaluate the number of items each time it's called, which usually
> > isn't necessary and adds time. Instead, work out the number of items
> > before going into the loop and simply refer to that for the number of
> > items in controlling the loop.
> >
> > Paul
> >
> > --
> > Paul M. Foster
> >
>
>
> What about using the right type of quotation marks for output:
>
> I use double quotes(") if I expect to output variables within the
> string, and single quotes when it's just a simple string.
>
> It's only a general rule of thumb and shouldn't be adhered to
> absolutely, but I remember a thread a while back that showed the speed
> differences between the two because of the extra parsing PHP does on
> double quoted strings.
>
>
That should be on the stackoverflow.com
It compare the string parsing with or without variables embeded
and the important of comma operator when ` echo ` data

use
echo 'something', 'other'

but not
echo 'something' . 'other'


Eric,


> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


Re: [PHP] Reliable way to identify Ogg types?

2010-01-26 Thread Eric Lee
Hi Micheal,

One of way for this should be by checking the header of the file with its
OggS magic number.
You may take a look at this page to see if it could help !

http://en.wikipedia.org/wiki/Ogg


But I'am confused that the mime type should be enough what type of data its
coming !
Are there are any more  things you need to concern ?


Thanks,


Regards,
Eric,


On Wed, Jan 27, 2010 at 11:23 AM, Michael A. Peters  wrote:

> When I use fileinfo on an uploaded Ogg file, the mime it returns is
> Application/Ogg which is almost useless.
>
> Is there a reliable php way, preferably without needing to execute shell
> commands, to positively identify a file as Ogg Theora or Ogg Vorbis?
>
> Thanks for suggestions.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Magic Methods not working

2010-01-26 Thread Eric Lee
On Wed, Jan 27, 2010 at 11:04 AM, Paul M Foster wrote:

> I have a class which instantiates other classes, and has a magic method
> like this:
>
> function _get($classname)
> {
>return $this->instantiate($classname);
> }
>
> Obviously, the class also has an instantiate method which does what it
> says.
>
> Here's the problem: When I call the instantiate method, it works fine,
> like this:
>
> $db = $sc->instantiate('database');
>
> But when I do the following, it *doesn't* work:
>
> $db = $sc->database;
>
> In fact it does not call the instantiate() method; I've placed a print
> statement in the instantiate() method which fires at then end of the
> routine. That statement doesn't fire with the above code.
>
> The docs on magic methods are pretty slim, so I'm not sure what it is
> I'm missing. Can someone enlighten me?
>
> Paul
>
>
Paul,

I seem that you should missed the required underscore " _  "
It should the __get() but not _get().
Shall this help ?

And here is a quick test !!

[ [ [
class test
{
public $varname = 1000;

public function __get($name)
{
return $this->init($name);
}

public function init($name)
{
return new test();
}
}

$t = new test();
$db = $t->database;
if (is_object($db))
{
echo $db->varname;
}

] ] ]


Regards,
Eric,


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


Re: [PHP] Speed of sending email .. can I put them in a queue rather than wait?

2010-01-26 Thread Eric Lee
Hi, all

I'am doubted about installing a local mail server for just low volume
mailing.
May I ask all yours professional what do you think about it ?


Thanks in advanced.



Regards,
Eric,




> --
> Jim Lucas
> NOC Manager
> 541-323-9113
> BendTel, Inc.
> http://www.bendtel.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Speed of sending email .. can I put them in a queue rather than wait?

2010-01-26 Thread Eric Lee
On Tue, Jan 26, 2010 at 12:02 PM, Angus Mann  wrote:

> Hi all.
>
> I'm currently using the phpmailer class from phpmailer.worxware.com to
> send datatbase -populated emails to clients.
>
> At the moment I'm runninng PHP on Windows and using the built-in sendmail
> equivalent packaged with XAMPP. It uses a remote SMTP that authenticates by
> prior logging into a POP account.
>
> The number of emails sent is very small. Each one is only sent after a user
> fills out a form and presses send.
>
> But there is a noticable lag of about 5 or sometimes 10 seconds after
> pressing "send" before the user sees the "Mail sent" page. I presume the
> reason for the lag is the time spent logging on and off a remote POP, then
> SMTP server, transferring the data etc.
>
> It would be better if this happened in the background - that is, the user
> could get on with doing his next task while the emails sat in a queue in the
> backgorund, being lined up and sent without PHP waiting for the process to
> finish.
>
> Can anybody recommend a good way of doing this? Is Mercury Mail going to
> help me here?
>
>
HI Angus,

+1 I agree on what Paul already said .
As in fact you were just to sent out low volume mails.
Create a table and queue all pending mails in that then use windows
scheduled tasks to perform the actual work
if that is not a real-time mail.


One thing to note, php on windows does't support specify username and
password.
But only hostname / IP Address and port only.


I can not help much
but just few more suggesions.

Hope these help

Eric,
Regards,


Re: [PHP] Upload file on IE8

2010-01-25 Thread Eric Lee
On Tue, Jan 26, 2010 at 6:41 AM, Ernie Kemp  wrote:

>   Good Day,
>
>
>
> I’m having an issue with IE8, when I go to load a file the
> program is not filling the $_FILES['user_file']['type']  .
>
>   When I display  “echo  "Start".$_FILES['pix']['type']."End";”  
> in IE8 I get “StartEnd” with nothing in between.  I expected “image/pjpeg".
>
>
>
> On FireFox I get “image/jpeg".
>
>
>
> Any suggestions?
>
> Thanks,
>
> /Ernie
>
>
>
>  I remember a setting from some elsewhere IE 8 was disable set file path
> location
> by default from the options dialog. Did you enabled this already ? If not,
> you may give it a shoot to see than !
>

> Hope this help
>
>
> Eric,
> Regards,
>

>
>
>
>
>


Re: [PHP] Foreign Characters Break in MySQL

2010-01-21 Thread Eric Lee
Hi, all,

I'am not able test it out now.
Did you tried to change the collation to utf8_bin from utf8_general_ci ?


Eric,
Regards,


On 1/22/10, Ryan Park  wrote:
>
> Forgot to reply all.
>
> You can see that it's in the middle of the sql statement.
> It looks fine here but some how it breaks during the query.
>
>  mysql_connect("localhost", "adminID", "password") or die(mysql_error());
> echo "Connected to MySQL";
>
> mysql_select_db("databasename") or die(mysql_error());
> echo "Connected to Database";
>
> $sql = "INSERT INTO xe_modules (module_srl, module, module_category_srl,
> layout_srl, menu_srl, site_srl, mid, skin, browser_title, description,
> is_default, content, open_rss, header_text, footer_text, regdate) VALUES
> ('135', 'bodex', '0', '53', '0', '0', 'free', 'xe_default', '자유게시판 ', '',
> 'N', '', 'Y', '', '', UNIX_TIMESTAMP());";
>
> mysql_query($sql) or die(mysql_error());
>
> mysql_close();
> ?>
>
> On 1/21/2010 5:19 PM, Jim Lucas wrote:
>
>> Ryan Park wrote:
>>
>>
>>> Hello I'm currently trying to use PHP to insert foreign characters into
>>> one of the mysql database tables.mysql_query() worked seamlessly, but when I
>>> check the inserted data on phpMyAdmin it shows the foreign characters in
>>> broken letters, like this ì‹œíŒ<- jibberish...The foreign characters show
>>> fine when I'm typing it out on my editor to code PHP, but it gets broken
>>> into unrecognizable symbols when put into mysql database columns.
>>> I tried to create the same thing this time through phpMyAdmin console and
>>> it worked great, the foreign characters showed correctly as they should.The
>>> column that I'm trying to put the foreign characters into is set as
>>> utf8_general_ci.I wish to use PHP to insert the data into the database
>>> because I'll be inserting massive amounts of them at once, so I just can't
>>> continue with this problem at hand.
>>> I'll greatly appreciate any help, thank you.
>>>
>>> _
>>> Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
>>> http://clk.atdmt.com/GBL/go/196390709/direct/01/
>>>
>>>
>> How about showing a little of the insert code.  ie: how you are gathering
>> the
>> data, how you are preping the data, and the actual insert statement.
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS

2010-01-16 Thread Eric Lee
Hi,

As I know that php did't setting user name and password.
So, just install any smtp server with authenticaton set to "no
authentication"
Much list IIS smtp server.



Eric,
Regards,


On 1/16/10, Andy Shellam  wrote:
>
> Hi,
>
> >
> > Also http://www.softstack.com/freesmtp.html which vikash mentioned works
> > through outlook settings.
> >
> > Anyways the below will help-
> >
> > http://php.net/manual/en/ref.mail.php
> >
> > http://glob.com.au/sendmail/
>
>
> Personally, I always found hMailServer to be perfectly reliable as a relay
> on Windows - just install it and SMTP to localhost - nothing more, nothing
> less.
>
> Andy


Re: [PHP] How to get a string from C library into PHP via SWIG?

2010-01-05 Thread Eric Fowler
I will expose only one function, prototyped like the foo() example I described.

cstring.i is not implemented for a PHP target (wah).

I think I will go the shell approach. I have enough time in this already.

Eric

On Tue, Jan 5, 2010 at 6:26 PM, Nathan Nobbe  wrote:
> On Tue, Jan 5, 2010 at 4:38 PM, Eric Fowler  wrote:
>>
>> A little more information: my crashes all relate to handling the char
>> datatype. Floats and ints are happy.
>>
>> I suspect that a char type in PHP is not the same as a char type in C.
>> But I am not sure at all.
>>
>> More recently I have used cmalloc.i to allocate arrays of chars and
>> floats. The floats are happy, the chars crash upon allocation.
>
> neat, swig generates php extensions.  i wonder Eric, how much functionality
> you intend to expose to php, a series of functions, classes?  from the
> sounds of your earlier description i would imagine maybe one class or a
> single set of functions to operate on a single string variable, with
> additional parameters for metadata.
> im curious, if youre sold on the generator, or if youre interested to just
> try your hand writing an extension.  if youre strong w/ C you could probly
> crank it out quickly.  another option would be to version the generated
> (swig) C, and repair it by hand, putting those changes in a branch.  during
> subsequent generations, you could merge the work from said branch and
> iterate on that.
> of course the other option is to figure out swig, lol.  anyways, is this C
> of yours for a private project or is it something i could take a peak at; im
> halfway curious what youre working w/.
> o, and guess what, reading through the swig php page, i discovered you can
> write php extensions 'in c++', by creating a thin C wrapper - wow, i had
> never thought of that, lol.
> -nathan

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



Re: [PHP] How to get a string from C library into PHP via SWIG?

2010-01-05 Thread Eric Fowler
A little more information: my crashes all relate to handling the char
datatype. Floats and ints are happy.

I suspect that a char type in PHP is not the same as a char type in C.
But I am not sure at all.

More recently I have used cmalloc.i to allocate arrays of chars and
floats. The floats are happy, the chars crash upon allocation.

Weird.

Eric

On Tue, Jan 5, 2010 at 2:56 PM, Nathan Nobbe  wrote:
> On Tue, Jan 5, 2010 at 3:42 PM, Eric Fowler  wrote:
>>
>> Hm, that could work, but it does produce overhead.
>
> you should consider your overall communication paradigm.  im very loosely
> familiar w/ swig, basically ive heard of it ...
> anyways, you have a few options for communication,
> . shell (call php from C or the other way around)
> . php extension, this may not make sense depending on what your C is doing
> and is by far the most complex
> . network protocol, socket, http or other..
> can you tell us a little bit more about what youre trying to accomplish and
> specifically how C and php are communicating in general in your application?
> -nathan

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



Re: [PHP] How to get a string from C library into PHP via SWIG?

2010-01-05 Thread Eric Fowler
This is going to the list per Nathan's suggestion.

I confess I am doing this the hard way because I want to get a handle
on how to pass across that boundary.

My current angle of attack is to use the malloc.i functions in swig to
handle those strings.

I will keep you all posted. I know you care. :-)

Eric


I have a software library that parses strings into a C language
structure. It is a utility for C programmers.

It contains a utility function that takes the output structure and
formats it as a string for display.

The goal is to demonstrate the functionality by permitting users to
enter strings into a text box and press a button.
The string will be passed into my code, parsed, formatted as a
different kind of string, and returned, where it will be
displayed on the web site.

The code is being shipped as a Windows DLL but for the web site I am
working with Linux dynamic libraries (*.so).
I am able to call functions within the binary from PHP now, but
pointers within PHP are not working far less crossing the
PHP/C Line Of Death without dying.


please keep the responses on list for the benefit of others.

well, if you have an .so, honestly i might spend the effort to wrap it
up in a simple extension.

but if you want to roll something out quickly, i would probly just
invoke it over the shell via shell_exec() or similar.

i cant imagine what sort of noticeable impact you would see in
performance going over the shell in this case.  honestly, i think the
question is how much work do you want to do.  also, do you intend to
share this functionality w/ other php programers, that might be an
argument for an extension.

do you already have a C based program that loads up the library from
the cli and uses STDIN / STDOUT, if so i think going over the shell is
a no-brainer..

On Tue, Jan 5, 2010 at 2:56 PM, Nathan Nobbe  wrote:
> On Tue, Jan 5, 2010 at 3:42 PM, Eric Fowler  wrote:
>>
>> Hm, that could work, but it does produce overhead.
>
> you should consider your overall communication paradigm.  im very loosely
> familiar w/ swig, basically ive heard of it ...
> anyways, you have a few options for communication,
> . shell (call php from C or the other way around)
> . php extension, this may not make sense depending on what your C is doing
> and is by far the most complex
> . network protocol, socket, http or other..
> can you tell us a little bit more about what youre trying to accomplish and
> specifically how C and php are communicating in general in your application?
> -nathan

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



Re: [PHP] How to get a string from C library into PHP via SWIG?

2010-01-05 Thread Eric Fowler
Hm, that could work, but it does produce overhead.

Thank you.

Eric

On Tue, Jan 5, 2010 at 1:29 PM, Ashley Sheridan
 wrote:
>
> On Tue, 2010-01-05 at 13:29 -0800, Eric Fowler wrote:
>
> I have a need to call a C language function from a PHP script.
>
> The function, which I wrote, looks like this:
>
> /*
> * foo(): Takes a string in sIn and writes another string into sOut
> according to what is passed in, and the
> * value at *pcch. Will not write more than *pcch bytes to output,
> including null terminator.
> * Upon return, *pcch contains number of chars written to sOut.
> */
> void foo(const char * sIn, char * sOut, size_t * pcch);
>
> So basically I need to pass down a string, and get back a string.
>
> I have been using swig but clearly I ain't getting it (I am good in C
> but new to PHP). Lots of warnings, crashes, and so on. No happiness.
>
> The swig docs show how to pass strings between python, java, etc., and
> C, but nothing on C <---> PHP.
>
> Can anyone help me with a fragment of sample code, or a link?
>
> Thanks
>
> Eric
>
>
> Can't you just compile the C into an executable and call it from a shell? 
> There are several ways to retrieve input from shell programs.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

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



[PHP] How to get a string from C library into PHP via SWIG?

2010-01-05 Thread Eric Fowler
I have a need to call a C language function from a PHP script.

The function, which I wrote, looks like this:

/*
* foo(): Takes a string in sIn and writes another string into sOut
according to what is passed in, and the
* value at *pcch. Will not write more than *pcch bytes to output,
including null terminator.
* Upon return, *pcch contains number of chars written to sOut.
*/
void foo(const char * sIn, char * sOut, size_t * pcch);

So basically I need to pass down a string, and get back a string.

I have been using swig but clearly I ain't getting it (I am good in C
but new to PHP). Lots of warnings, crashes, and so on. No happiness.

The swig docs show how to pass strings between python, java, etc., and
C, but nothing on C <---> PHP.

Can anyone help me with a fragment of sample code, or a link?

Thanks

Eric

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



Re: [PHP] not able to use mysql server

2009-12-30 Thread Eric Lee
On 12/30/09, Jignesh Thummar  wrote:
>
> It is problem with mysql client, it's not able to connect with mysql
> server.
> Either mysql server is not running or windows firewall is blocking to the
> access of port 3306. Try to disable firewall.
>
> -Jignesh
>
> On Wed, Dec 30, 2009 at 11:41 AM, Sudhakar 
> wrote:
>
> > hi
> >
> > i am using windows vista and installed wamp server, initially i installed
> > wamp and accessed phpmyadmin and while setting a password for the root i
> > did
> > a mistake and could not access phpmyadmin and also renamed some php files
> > so
> > i uninstalled wamp server and re installed
> >
> > now the problem i am facing is when i click on mysql.exe located at
> > D:\wamp\bin\mysql\mysql5.1.36\bin i am getting the following error
> > error 2003 cant connect to Mysql server on localhost 10061
> >
> > in config.inc.php located at d:\wamp\apps\phpmyadmin3.2.0.1 i have the
> > following
> > $cfg['Servers'][$i]['host'] = 'localhost';
> > $cfg['Servers'][$i]['port'] = '3306';
> > $cfg['Servers'][$i]['auth_type'] = 'config';
> > $cfg['Servers'][$i]['user'] = 'root';
> > $cfg['Servers'][$i]['password'] = 'root';
> > $cfg['Servers'][$i]['AllowNoPassword'] = true;
> >
> > along with others.
> >
> > when i type http://localhost i am able to see the welcome screen of wamp
> > and
> > can click on phpinfo but when i click on phpmyadmin it takes a while to
> > load
> > and a blank screen appears
> >
> > also i have stopped all services and restarted all services from the
> > wampserver icon in the system tray, normally the colors change from red
> to
> > yellow to white, the color is at yellow and does not change to white
> >
> > how do i solve the error error 2003 cant connect to Mysql server on
> > localhost 10061 so that i can use phpmyadmin
> >
> > please advice.
> >
> > thanks.
> >
>

Are there any error entries of mysql server on the event viewer ?
Also, what is the starting state of mysql server on the services console ?
You can found all tool on administrative folder on the start menu.


Re: [PHP] MySQL Increment/Decrement

2009-12-28 Thread Eric Lee
Ben

It seems that you can just update the column with a update query like this,

update table set field = field + 1 where some condition

This might be the thing you need.


Eric



On 12/29/09, Ben Miller  wrote:
>
> I hope this isn't a bone-head question - Is there a MySQL query that will
> increment/decrement the value in an integer column with a single query - in
> other words, I don't have to run a SELECT query to get the value,
> add/subtract to/from the value, and then run an UPDATE query to store the
> new value?
>
>
>
> Thanks in advance.
>
>
>
> Ben
>
>


RE: [PHP] Issue with $HTTP_POST_VARS Not getting Variables

2009-12-11 Thread Eric Lommatsch
Doh, I should have thought of that!
 
Thanks, that is what happens when you use code that someone else has writen
and included with a software package. At least I assumed that the code was
already written correctly to accept parameters. I guess it wasn't.
 
Thank you
 
Eric H. Lommatsch
Programmer
360 Business 
 
 


From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, December 11, 2009 1:39 PM
To: Eric Lommatsch
Cc: php-general@lists.php.net
Subject: Re: [PHP] Issue with $HTTP_POST_VARS Not getting Variables


On Fri, 2009-12-11 at 13:37 -0700, Eric Lommatsch wrote: 

Hello,
 
I am working with a login page to use with an application that we are
planning to make available as a web service. The login.php page
itself works
correctly, however when I try and pass parameters to the login page
the are
not being recognized by the login.php page. 
 
Here is the basic code that I am dealing with to attempt to the the
variables:
 


When I enter the url
http://localost/index.php?username=jasperadmin&password=**

Where localhost is the ip address of my server and ** is the
password of
the user that is logging in, I am not having the username questioned
and the
login.php isacting as if I have not entered any parameters. 

Why are the parameters not being accepted?

I am using php version 5.2.6 on a ubuntu linux box

 
Thank you
 
    Eric H. Lommatsch
Programmer
360 Business 
 


First off, take out those HTTP_POST_VARS lines. That's an outdated way of
accessing post variables, and is made useless by the next two lines that
follow it.

Second, the two lines you are using at the end there are for post data, but
you clearly use get data in the URL! If you have to accept the username and
password from both get and post, change the lines to use $_REQUEST instead of
$_POST.


Thanks,
Ash
http://www.ashleysheridan.co.uk





[PHP] Issue with $HTTP_POST_VARS Not getting Variables

2009-12-11 Thread Eric Lommatsch
Hello,
 
I am working with a login page to use with an application that we are
planning to make available as a web service. The login.php page itself works
correctly, however when I try and pass parameters to the login page the are
not being recognized by the login.php page. 
 
Here is the basic code that I am dealing with to attempt to the the
variables:
 


When I enter the url
http://localost/index.php?username=jasperadmin&password=**

Where localhost is the ip address of my server and ** is the password of
the user that is logging in, I am not having the username questioned and the
login.php isacting as if I have not entered any parameters. 

Why are the parameters not being accepted?

I am using php version 5.2.6 on a ubuntu linux box

 
Thank you
 
Eric H. Lommatsch
Programmer
360 Business 
 


[PHP] Re: using mysql_close() = best practice?

2009-10-26 Thread Eric Bauman

On 24/10/2009 7:36 PM, Kim Madsen wrote:

Hi

PHP closes an open db connection when the script is done.

I've read somewhere that in PHP6 this behaviour will dissapear, is this
true? In that case using mysql_close() would definetly be best practice
in all current scripts, to make it portable.

A nice solution would probably be adding a end_mysql() or page_end() to
all pages and put whatever is needed into that function (mysql_close,
mysql_free_result, etc)



I can't say with any certainty whether that is true or not - but it 
certainly seems like it is false. Non-persistent connections are 
destroyed automatically by the garbage collector when no more references 
are detected. See 
http://au2.php.net/manual/en/language.types.resource.php#language.types.resource.self-destruct


That said, I believe it to be good practice to close any opened database 
connection. All my database methods are wrapped in a class, however, so 
I do this in the destructor.


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



[PHP] What is the best practice for adding persistence to an MVC model?

2009-10-26 Thread Eric Bauman
I'm in the process of implementing an ultra-light MVC framework in PHP. 
It seems to be a common opinion that the loading of data from a 
database, file etc. should be independent of the Model, and I agree. 
What I'm unsure of is the best way to link this "data layer" into MVC.


I've considered a few options:

*Datastore interacts with Model*

//controller
public function update()
{

 $model = $this->loadModel('foo');
 $data = $this->loadDataStore('foo', $model);

 $data->loadBar(9); //loads data and populates Model
 $model->setBar('bar');
 $data->save(); //reads data from Model and saves

}

*Controller mediates between Model and Datastore*

Seems a bit verbose and requires the model to know that a datastore exists.

//controller
public function update()
{

 $model = $this->loadModel('foo');
 $data = $this->loadDataStore('foo');

 $model->setDataStore($data);

 $model->getDataStore->loadBar(9); //loads data and populates Model
 $model->setBar('bar');
 $model->getDataStore->save(); //reads data from Model and saves

}

*Datastore extends Model*

What happens if we want to save a Model extending a database datastore 
to a flatfile datastore?


//controller
public function update()
{

 $model = $this->loadHybrid('foo'); //get_class == Datastore_Database

 $model->loadBar(9); //loads data and populates
 $model->setBar('bar');
 $model->save(); //saves

}

*Model extends datastore*

This allows for Model portability, but it seems wrong to extend like 
this. Further, the datastore cannot make use of any of the Model's methods.


//controller extends model
public function update()
{

 $model = $this->loadHybrid('foo');  //get_class == Model

 $model->loadBar(9); //loads data and populates
 $model->setBar('bar');
 $model->save(); //saves

}



Any input on the "best" option - or alternative - would be most appreciated.

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



Re: [PHP] Re: Insult my code!

2009-10-12 Thread Eric Bauman

On 12/10/2009 9:21 PM, David Otton wrote:

2009/10/11 Eric Bauman:


As before, please feel free to insult my code. ;-) Any and all feedback is
of course most appreciated.


I know you're more concerned with structure, but your checkInt()
method is arguably buggy/has an un-noted assumption. It accepts ints
formatted as ints and strings, but not floats:



*sigh* sometimes I really wish PHP allowed one to be a bit more 
heavy-handed with types (optional real type hinting would be nice).


I guess I only ever worried about string (from DB) and int (internal 
call) as in my specific use I would never be passing a float.
You make an excellent point however; I suppose in the interests of 
completeness, forward compatibility etc. I should take into account more 
possibilities. Perhaps I should just throw an exception in deposit() 
etc. if the argument isn't int and worry about converting elsewhere.


Also thanks for the sample TestCase code! I've never really thought 
about unit testing in PHP, despite doing so in Java etc. Reading about 
PHPUnit brought me on to phpUnderControl - interesting stuff!



Best regards,
Eric

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



[PHP] Re: Insult my code!

2009-10-11 Thread Eric Bauman

On 7/10/2009 5:34 PM, Eric Bauman wrote:

Hi there,

I'm in the process of trying to wrap my head around MVC, and as part of
that, I'm attempting to implement a super-tiny MVC framework.

I've created some mockups of how the framework might be used based
around a very simple 'bank', but I'm trying to get some feedback before
I go and implement it, to make sure I'm actually on the right track.

Any thoughts would be much appreciated!

Model - http://www.pastebin.cz/23595
Controller - http://www.pastebin.cz/23597
View - http://www.pastebin.cz/23598
Template - http://www.pastebin.cz/23599


Hi again,

I've done quite a bit of reading, thinking and coding based on all the 
feedback I received from my original post.


I have since come up with this:

Model - http://www.pastebin.cz/23857
Controller - http://www.pastebin.cz/23858
View - http://www.pastebin.cz/23859
Persistence - http://www.pastebin.cz/23860

As before, please feel free to insult my code. ;-) Any and all feedback 
is of course most appreciated.


Best regards,
Eric

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



Re: [PHP] Insult my code!

2009-10-08 Thread Eric Bauman

On 8/10/2009 5:18 PM, Mert Oztekin wrote:

Hi Paul,

As I agree some of your thoughts, I want to add my opinion also.
Yes the code should work. That is why we earn Money. If it doesnt work, then we are on 
fire. But things like OOP or MVC weren't invented for a better running code. They are 
invented so the codes will going to be much more clean, readable, reusable, maintainable. 
"Running codes" is not enough.

Eric asked about how his MVC structure looks. And we are trying to help what we know 
about MVC. He didn't asked if the code is fine for running. So giving an answer "The 
real key is, does it work, and can it be maintained" is not enough and not really 
helpful to him on MVC concept. If you need just a running and maintainable project, you 
don't need to use MVC (MVC is not all about that). We are not criticizing his code(the 
code is really fine(except injection problem :-) ) and very readable)


Eric,

As Martin said, All the business logic should be in Model. Controller should not tell a 
model "Save it to this database, select it from this table, use this 
db_adapter" etc. A controller is like a maestro of the system. It askes the model to 
play piano loud. But it wont say which key of piano, the model should touch.

I suggest you to read this online book about Zend Framework and MVC. Its really 
really very helpful to understand the concept. Also example codes are very 
clean and good.
http://www.survivethedeepend.com/zendframeworkbook/en/1.0


Take Care,

Mert
(sorry for my english)


Thanks for the link, it looks like an interesting read. Hopefully it 
will help me understand MVC better and hence allow me to improve my code 
design.


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



[PHP] Re: what is php4 popularity?

2009-10-08 Thread Eric Bauman

On 8/10/2009 4:28 PM, Paul M. wrote:

Hey guys, does anyone have a good link for an article where php4
popularity trends are examined? The best way for me to know php4 % and
php5 %. I appreciate any good suggestions.


Here's a pretty graph comparing PHP version usage and time: 
http://www.nexen.net/images/stories/phpversion/200810/evolution.milieu.png


Source (French): http://www.nexen.net/chiffres_cles/phpversion/

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



Re: [PHP] Insult my code!

2009-10-08 Thread Eric Bauman

On 8/10/2009 1:20 AM, Andrea Giammarchi wrote:


So far I stopped at the first line, the constructor, where I can spot with what I can 
read SQL injections "everywhere"

I hope here is a proper validation there, 'cause as is, sounds truly dangerous, 
since you are not using bindParams or other PDO related techniques to avoid 
input problems.

About the rest I kinda agree with the proper model controller, rather than just 
a reader.

Regards


To: php-general@lists.php.net
Date: Wed, 7 Oct 2009 17:34:35 +1100
From: baum...@livejournal.dk
Subject: [PHP] Insult my code!

Hi there,

I'm in the process of trying to wrap my head around MVC, and as part of
that, I'm attempting to implement a super-tiny MVC framework.

I've created some mockups of how the framework might be used based
around a very simple 'bank', but I'm trying to get some feedback before
I go and implement it, to make sure I'm actually on the right track.

Any thoughts would be much appreciated!

Model - http://www.pastebin.cz/23595
Controller - http://www.pastebin.cz/23597
View - http://www.pastebin.cz/23598
Template - http://www.pastebin.cz/23599

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



_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010


The linked code was supposed to be more of a mockup than anything, with 
the functions a bit of filler to try and show what I'm trying to do.


With regard to the SQL injection, I try not to make the problems with my 
code quite so blatant. :-)


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



Re: [PHP] Insult my code!

2009-10-07 Thread Eric Bauman

On 7/10/2009 7:25 PM, David Otton wrote:

2009/10/7 Eric Bauman:


Any thoughts would be much appreciated!


One observation. "Model" isn't a synonym for "Database Table" - models
can be anything that encapsulates business logic. Requiring all your
models to inherit from Model is probably a bad idea.


Thank-you for responding.

Out of curiosity, why is this a bad idea? Is it also bad for views & 
controllers?



Cheers,
Eric

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



Re: [PHP] Insult my code!

2009-10-07 Thread Eric Bauman

On 7/10/2009 7:36 PM, Mert Oztekin wrote:

Seems ok.

Just a thought:

 Your model seems to be coded just for retreiving data. IMO you should 
code it for all possible actions(insert,update,delete,select). And also it 
should run without any database calls(you may create a new bank user in a page 
and use it than throw it away, so you wont have to need a database to save it).

 Your model may be more useable when it can holds the data 
itself(without retreiving it from db first), after that a save() method may 
inserts/updates it to db.



-Original Message-
From: Eric Bauman [mailto:baum...@livejournal.dk]
Sent: Wednesday, October 07, 2009 9:35 AM
To: php-general@lists.php.net
Subject: [PHP] Insult my code!

Hi there,

I'm in the process of trying to wrap my head around MVC, and as part of
that, I'm attempting to implement a super-tiny MVC framework.

I've created some mockups of how the framework might be used based
around a very simple 'bank', but I'm trying to get some feedback before
I go and implement it, to make sure I'm actually on the right track.

Any thoughts would be much appreciated!

Model - http://www.pastebin.cz/23595
Controller - http://www.pastebin.cz/23597
View - http://www.pastebin.cz/23598
Template - http://www.pastebin.cz/23599

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


Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve 
gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve 
mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz 
mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, 
bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar 
sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.



Thanks for the response!

You suggested that the model should run without any database calls. Do 
you mean that they should not exist in a model (ie. a controller should 
instantiate /and/ populate a model), or rather that it should be 
optional (ie. each method only updates the state of the object, and 
load() & save() must be explicitly called to interact with the DB)?


Or am I way off track.

Cheers,
Eric

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



[PHP] Insult my code!

2009-10-07 Thread Eric Bauman

Hi there,

I'm in the process of trying to wrap my head around MVC, and as part of 
that, I'm attempting to implement a super-tiny MVC framework.


I've created some mockups of how the framework might be used based 
around a very simple 'bank', but I'm trying to get some feedback before 
I go and implement it, to make sure I'm actually on the right track.


Any thoughts would be much appreciated!

Model - http://www.pastebin.cz/23595
Controller - http://www.pastebin.cz/23597
View - http://www.pastebin.cz/23598
Template - http://www.pastebin.cz/23599

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



Re: [PHP] new php script and sqlite

2009-09-08 Thread Eric Boo
On Tue, Sep 8, 2009 at 9:41 PM, Paul M Foster wrote:
> On Tue, Sep 08, 2009 at 11:20:01AM +0800, Eric Boo wrote:
>
>> Hi,
>>
>> I'm currently using a text file to store data which the php script
>> will read and write back to. I've a few questions:
>>
>> 1) I'm thinking of using sqlite, but not sure whether this will be
>> widely available on most hosts, as I intend for the php script to be
>> deployed without needing to much with much configuration. Is sqlite
>> included with most php setups?
>
> As I understand it, sqlite support is by default built into PHP. If so,
> then it should be supported anywhere.

Thanks for your reply.

I was under the impression that sqlite2 was supported widely by PHP,
but sqlite3 seems only to be enabled on php 5.3.0 by default.

My concern now is actually that users may find that their hosting
service providers don't provide sqlite3 out of the box.

Eric

>
>>
>> 2) Should I be using sqlite 2 or 3?
>
> Don't use version 2. It's deprecated.
>
> 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



[PHP] new php script and sqlite

2009-09-07 Thread Eric Boo
Hi,

I'm currently using a text file to store data which the php script
will read and write back to. I've a few questions:

1) I'm thinking of using sqlite, but not sure whether this will be
widely available on most hosts, as I intend for the php script to be
deployed without needing to much with much configuration. Is sqlite
included with most php setups?

2) Should I be using sqlite 2 or 3?

Thanks for your time!

Regards.

Eric

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



Re: [PHP] File Open Prompt?

2009-08-29 Thread Eric

- Original Message - 
From: "Eric" 
To: ; "Ralph Deffke" 
Cc: 
Sent: Saturday, August 29, 2009 5:01 PM
Subject: Re: [PHP] File Open Prompt?


> 
> - Original Message - 
> From: "Ashley Sheridan" 
> To: "Ralph Deffke" 
> Cc: 
> Sent: Saturday, August 29, 2009 3:16 PM
> Subject: Re: [PHP] File Open Prompt?
> 
> 
>> On Sat, 2009-08-29 at 09:03 +0200, Ralph Deffke wrote:
>>> are u shure, u dont send anything out before u send the headers? even one
>>> space would be too much.
>>> 
>>> ralph_def...@yahoo.de
>>> 
>>> "Dan Shirah"  wrote in message
>>> news:a16da1ff0908281328k641ea332v25d887c4de5b3...@mail.gmail.com...
>>> > >
>>> > > You will need to add some headers to the page to popup the prompt, at
>>> least
>>> > > with
>>> > > these.
>>> > >
>>> > > $filename = 'somefile.tif';
>>> > > $filesize = filesize($filename);
>>> > >
>>> > > header('Content-Type: application/force-download');
>>> > > header('Content-disposition: attachement; filename=' . $filename);
>>> > > header('Content-length: ' . $filesize);
>>> > >
>>> > > Eric
>>> > >
>>> > >
>>> >
>>> > I don't know what I'm doing wrong.  I've tried:
>>> >
>>> > header('Content-Description: File Transfer');
>>> > header('Content-Type: application/force-download');
>>> > header('Content-Length: ' . filesize($filename));
>>> > header('Content-Disposition: attachment; filename=' . basename($file));
>>> > readfile($file);
>>> > AND
>>> >
>>> > if (file_exists($new_file)) {
>>> > header('Content-Description: File Transfer');
>>> > header('Content-Type: application/octet-stream');
>>> > header('Content-Disposition: attachment; filename='.basename($new_file
>>> > ));
>>> > header('Content-Transfer-Encoding: binary');
>>> > header('Expires: 0');
>>> > header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
>>> > header('Pragma: public');
>>> > header('Content-Length: ' . filesize($new_file));
>>> > ob_clean();
>>> > flush();
>>> > readfile($new_file);
>>> > exit;
>>> > }
>>> >
>>> > But everything I do just sends heiroglyphics to the screen instead of
>>> giving
>>> > the download box.
>>> >
>>> 
>>> 
>>> 
>> Try putting all of that inside of a headers_sent(){} block. If nothing
>> is displayed, it means that you've already sent something to the
>> browser, so the headers have already been sent and the extra ones you
>> are sending do nothing. This sort of thing is shown in your error log
>> also.
>> 
>> If you still get the tif displayed as text, then are you sure that the
>> tif is valid?
>>
> 
> You may also try put these line at top of page to avoid anythings sent before
> your attachment headers
> 
> error_reporting(E_ALL);
> ini_set('display_errors', 1);
> 
> Which browsers you used to test it and  their versions ?
> 
> 

Also, did you browse it directly or through a secondary page ?
It should used on a second page.

i.e.

page1.php

download

download.php

header( 

-Eric

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

Re: [PHP] File Open Prompt?

2009-08-29 Thread Eric

- Original Message - 
From: "Ashley Sheridan" 
To: "Ralph Deffke" 
Cc: 
Sent: Saturday, August 29, 2009 3:16 PM
Subject: Re: [PHP] File Open Prompt?


> On Sat, 2009-08-29 at 09:03 +0200, Ralph Deffke wrote:
>> are u shure, u dont send anything out before u send the headers? even one
>> space would be too much.
>> 
>> ralph_def...@yahoo.de
>> 
>> "Dan Shirah"  wrote in message
>> news:a16da1ff0908281328k641ea332v25d887c4de5b3...@mail.gmail.com...
>> > >
>> > > You will need to add some headers to the page to popup the prompt, at
>> least
>> > > with
>> > > these.
>> > >
>> > > $filename = 'somefile.tif';
>> > > $filesize = filesize($filename);
>> > >
>> > > header('Content-Type: application/force-download');
>> > > header('Content-disposition: attachement; filename=' . $filename);
>> > > header('Content-length: ' . $filesize);
>> > >
>> > > Eric
>> > >
>> > >
>> >
>> > I don't know what I'm doing wrong.  I've tried:
>> >
>> > header('Content-Description: File Transfer');
>> > header('Content-Type: application/force-download');
>> > header('Content-Length: ' . filesize($filename));
>> > header('Content-Disposition: attachment; filename=' . basename($file));
>> > readfile($file);
>> > AND
>> >
>> > if (file_exists($new_file)) {
>> > header('Content-Description: File Transfer');
>> > header('Content-Type: application/octet-stream');
>> > header('Content-Disposition: attachment; filename='.basename($new_file
>> > ));
>> > header('Content-Transfer-Encoding: binary');
>> > header('Expires: 0');
>> > header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
>> > header('Pragma: public');
>> > header('Content-Length: ' . filesize($new_file));
>> > ob_clean();
>> > flush();
>> > readfile($new_file);
>> > exit;
>> > }
>> >
>> > But everything I do just sends heiroglyphics to the screen instead of
>> giving
>> > the download box.
>> >
>> 
>> 
>> 
> Try putting all of that inside of a headers_sent(){} block. If nothing
> is displayed, it means that you've already sent something to the
> browser, so the headers have already been sent and the extra ones you
> are sending do nothing. This sort of thing is shown in your error log
> also.
> 
> If you still get the tif displayed as text, then are you sure that the
> tif is valid?
>

You may also try put these line at top of page to avoid anythings sent before
your attachment headers

error_reporting(E_ALL);
ini_set('display_errors', 1);

Which browsers you used to test it and  their versions ?


- Eric


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

Re: [PHP] Converting URL's to hyperlinks.

2009-08-29 Thread Eric

- Original Message - 
From: "John Meyer" 
To: 
Sent: Friday, August 28, 2009 1:56 AM
Subject: [PHP] Converting URL's to hyperlinks.


> What sort of function would I need if I wanted to convert those URLs 
> from plain jane text?
> 

You should encode the url before printing as usual way

$url = htmlentities('http://www.mysite.com/index.php?act=1&t=10');

echo "mysite";


- Eric

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

Re: [PHP] File Open Prompt?

2009-08-28 Thread Eric

- Original Message - 
From: "Ashley Sheridan" 
To: "Dan Shirah" 
Cc: "PHP General" 
Sent: Saturday, August 29, 2009 3:10 AM
Subject: Re: [PHP] File Open Prompt?


> On Fri, 2009-08-28 at 15:03 -0400, Dan Shirah wrote:
> 
>> Greetings,
>> 
>> I'm having a problem trying to get a file download prompt.
>> 
>> Basically I have a page with image links.
>> 
>> When the link is clicked, the user is directed to another page I have. That
>> page finds the image path based on the image ID from the previous page.
>> 
>> Once the image path is found I copy the image to the local webserver and
>> rename the proprietary extension, .0D9 to .tif
>> 
>> Once the file is renamed to .tif I want the download prompt to come up.  You
>> know, where it says, "Open" "Save" "Cancel".
>> 
>> I've tried using:
>> 
>> $fp = fopen($new_file,"r") ;
>> header("Content-Type: image/tif");
>> while (! feof($fp)) {
>>$buff = fread($fp,filesize($new_file));
>>print $buff;
>>}
>> 
>> But that just gives me heiroglyphics on the screen instead of prompting the
>> user to download.
>> 
>> Here is my code that copies and renames the file:
>> 
>> if ($page != "" || $page != " ") {
>>  exec("xcopy ".$page." ".$topage."");
>> }
>> $orig_file = $topage."\\".$objectid.".0D9";
>> //echo $orig_file;
>> $new_file = $topage."\\".$objectid.".tif";
>> //echo $new_file;
>> 
>> rename($orig_file,$new_file);
>> 


You will need to add some headers to the page to popup the prompt, at least 
with 
these.

$filename = 'somefile.tif';
$filesize = filesize($filename);

header('Content-Type: application/force-download');
header('Content-disposition: attachement; filename=' . $filename);
header('Content-length: ' . $filesize);

Eric

>> Any ideas on how to make the browser give the download prompt for $new_file?
>> 
>> Thanks,
>> Dan
> 
> You need to send down the right headers to the browser, so that it knows
> it's meant to save the file, and not attempt to display it. If the link
> was to a file, you'd have certain header that informed the browser the
> mime type of the file.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 
>

Re: [PHP] Re: Best way to test for form submission?

2009-08-28 Thread Eric

- Original Message - 
From: "Adam Jimerson" 
To: 
Sent: Friday, August 28, 2009 11:21 AM
Subject: [PHP] Re: Best way to test for form submission?


> On 08/27/2009 11:09 PM, Adam Jimerson wrote:
>> This question might give away the fact that I am a php noob, but I am
>> looking for the best way to test for form submission in PHP.  I know in
>> Perl this can be done with
>> 
>> if (param)
>> 
>> but I don't know if that will work with PHP.  I have read the Learning
>> PHP 5 book and the only thing that was mentioned in the book was the use
>> of something like this
>> 
>> print "Hello ".$_POST['username']."";
> 
> Sorry copied and pasted the wrong line (long day)
> 
> if (array_key_exists('username',$_POST))

Here is another way

if (isset($_POST['username'])  && $_POST['username'] != '')
{ ...


>> 
>> I'm sure that this is not the best/recommended way to do this but I'm
>> hoping someone here will point me in the right direction.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

Re: [PHP] design pattern

2009-08-14 Thread Eric Butera
On Thu, Aug 13, 2009 at 4:45 PM, Ralph Deffke wrote:
> Hi Martin,
>
> thanks for ur efforts, this is a lot of good work.
>
> for my opinion the start is a bit too much theoretical and valid for all
> type of application. In simple words, u are too close to the book.
>
> I would love to have something closer to the purpose of PHP
> and its applications.
>
> if u have a look at the SMARTY documentation u have good explanation (and a
> bad example by the way concerned oop) what are the real world problem.
>
> When it comes to the final u find the most spagetti code in putting the page
> grafic designer toghether with the business logic.
>
> It would be great if this could be put in good oop patterns. As I can not
> see that with the little amount of time I have got, p l e a s e tell me what
> will come up on this edge?
>
> ralph_def...@yahoo.de
>
>
> "Martin Scotta"  wrote in message
> news:6445d94e0908131322w722a37bbi24983ae143c5d...@mail.gmail.com...
>> On Thu, Aug 13, 2009 at 4:04 PM, Ralph Deffke 
> wrote:
>>
>> > so guys
>> >
>> > why u don't discuss Martins outcome?
>> > is there no advice, idears?
>> > isn't there a need for it?
>> > nobody want to use it?
>> >
>> > I WANT TO LEARN
>> >
>> > ralph_def...@yahoo.de
>> >
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>> I was following the entirely conversation, I must admit I wasn't expecting
>> such thread.
>>
>> It is not common to see design patterns applied to PHP applications and,
> is
>> more common to don't see PHP applications. They are just scripts. Many
>> scripts in a simple folder puts together to do the dirty work.
>>
>> Of course there are many kicking-ass PHP Applications, but they are a
>> minimum portion compared to old-fashioned scripts.
>>
>> So, how do we start writing good quality PHP Applications? That's a very
>> good question, and I don't know the answer, but I think by talking about
>> design patterns we are in a good way.
>>
>> It's true that using design patterns the code will run slower, but it'll
> be
>> flexible, maintable, and the most important: simple.
>> After all that's what we are looking for, something really simple that
> make
>> our life as developers happier every day. How do you explain the crescent
>> number of php frameworks for rapid development?
>>
>> PHP core team has taken OOP seriously.
>> Do you note the new SPL objects? The core team creates those objects using
>> many designs patterns.
>> By example the RecursiveDirectoryIterator and it's family use the
> decorator
>> pattern.
>> Also features such as "late static binding" were added because a design
>> pattern.
>>
>> I think there will be some "separation" in the community, those who will
>> stay using scripts and those who will use heavily OOP. I do not know who
> the
>> "dark side" will be, xD
>>
>>
>> --
>> Martin Scotta
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

L - O - L.  Little time you've got?  I just glanced at the list and
you seem to have a lot of time typing up incoherent messages.  I would
suggest reading some books on programming architecture instead of
typing out all sorts of silly emails that don't make any sense.  As it
turns out, if you know how to program in theory, the language itself
becomes moot.  Bai!

-- 
http://www.ericbutera.us/

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



Re: [PHP] Warning: OutsourcingRoom.com

2009-08-05 Thread Eric Butera
On Wed, Aug 5, 2009 at 3:06 AM, Ashley Sheridan 
wrote:
> On Tue, 2009-08-04 at 20:49 -0700, Steve wrote:
>> Daniel Brown wrote:
>> >     Just as a heads-up, in case you guys weren't yet aware (cross-posting):
>> >
>> >     Elance.com was the victim of an SQL injection attack earlier this
>> > summer (they apparently missed our billions of threads on sanity).
>> > According to their folks, only names, company names, phone numbers,
>> > and email addresses were taken.  Whether or not that's true, I don't
>> > know, but that's beyond the scope of this warning.
>> >
>> >     The most recent attempt to get more of your personal information
>> > comes from a (*possibly* legitimate) website named
>> > OutsourcingRoom.com.  If you have been a member of Elance, you may
>> > have already received the message from OSR that claims that you signed
>> > up with them, and gives you a username and password.  Now, I'm not
>> > here to tell you guys and gals what to do, but taking the facts into
>> > account - the stealing of private information by breeching the
>> > security of a competitor - it's entirely up to you as to whether or
>> > not you'll consider OSR a trustworthy business.  Chances are, they'll
>> > not only charge you for using the service, but will also be so kind as
>> > to reuse (or redistribute) your private and financial information,
>> > should you be willing to give it to them.
>> >
>> >     We've already received numerous hits on our network for
>> > OutsourcingRoom.com and one or two other shoddy attempts to gain more
>> > information.  Today the emails seem to have picked up significantly,
>> > and appear to be not only valid, but professionally-crafted.
>> > Thankfully, we were anticipating such, after being alerted to the
>> > attack by Elance themselves.  Perhaps a bit embarrassing for them, but
>> > it was a good move to mitigate the damage post-fact, in my opinion.
>> >
>> >     That's it.  Just trying to keep everyone from getting scammed and
>> > screwed.  For more information, check Google, as always.  ;-P
>> >
>> >
>>
>> I got that email. I was wondering what that was about. Thanks for the info!
>>
> Well, I try not to give out my details to too many people each month,
> and this month they were beat to it by a nice fellow in Nigeria who I'm
> helping out by letting him put some money into my account. Next month I
> had originally planned to invest in those berrys everyone is talking
> about and some watches, and then after that, I need to update my account
> details on Ebay (I forgot I even had an account with them!) as they keep
> asking me to go and do it because of a security update they've made.
>
> Ho hum...
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Har har.  This was not a mindless 411 scam.  It is a bit different
when an actual site people use gets hacked and their personal
information stolen.  I too received one of these emails and it was
very convincing.  It has my exact username from the Elance site and
was crafted in such a way that it seems this new site was a partner
with Elance somehow.

-- 
http://www.ericbutera.us/

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



Re: [PHP] Need quick got written up yesterday!! OUCH (RESOLVED)

2009-08-04 Thread Eric Butera
On Tue, Aug 4, 2009 at 7:19 PM, Govinda wrote:
> Terion,
>
> I've done a lot of backend programming, but I'm even more newbie than you in
> PHP...  so take this from an equal, & FWIW:
> I think we in this work can all get dry/impersonal and grouchy at times, but
> to rephrase the others, in perhaps more encouraging terms:
> I think the guys just want the natural satisfaction of seeing you grow in
> understanding.  it is really fulfilling to help people; we all love helping
> someone in need!  But we all also want to see our investment stick and make
> a difference in the long run.  Putting out fires is ok once in a while, but
> much more satisfying is contributing to someone getting good at this stuff,
> even if at a humble pace.
>
> 
> John Butler (Govinda)
> govinda.webdnat...@gmail.com
>
>
>
>

Yea that whole teach a person to fish... yadda yadda. :)

-- 
http://www.ericbutera.us/

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



Re: [PHP] Internal PHP caching methodology

2009-07-20 Thread Eric Butera
On Sat, Jul 18, 2009 at 7:14 AM, Daniel Kolbo wrote:
> Daniel Kolbo wrote:
>> Eric Butera wrote:
>>> On Thu, Jul 16, 2009 at 5:50 PM, Daniel Kolbo wrote:
>>>> Hello,
>>>>
>>>> Call me a dreamer...but I got to ask.
>>>>
>>>> Is there any software for helping speed up PHP by utilizing internal PHP
>>>> caching?
>>>>
>>>> I am not talking about the external php cache/header control.  Smarty
>>>> caching doesn't give me the control I need either.
>>>>
>>>> I would like to cache to a finer level than page by page, but rather on
>>>> a module by module basis.  Each of my pages contains a subset of
>>>> modules.  The content of these modules changes based upon certain
>>>> criteria (link, time, session data, but is sometimes static across the
>>>> site).  I would like to be able to cache individual "modules"
>>>> (preferably based upon frequency and time to generate).
>>>>
>>>> I am trying to develop a way to do this, but I have to think a brighter
>>>> mind has come before me and hopefully arrived at a solution.
>>>>
>>>> As always any help/thoughts are much appreciated, except for that one
>>>> guy's comments (you all know who I am talking) ~ jk ;)
>>>>
>>>> Thanks,
>>>> `
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> Have you actually profiled your code to see where the pain points are
>>> vs saying 'module?'  Are you also running an opcode cache?  From there
>>> you can use data, block, or full page caching.  Finally you can figure
>>> out if you want to store it in flat files or memory.  I'd start by
>>> knowing what is actually the slow part using Xdebug and nail a few
>>> down.
>>>
>>> There is no end all solution.  Some pages really don't have a lot
>>> going on and are hardly updated so full page is fine.  Others might
>>> have something that is hard to generate on a sidebar, so block caching
>>> would be more suitable for that.  As previously mentioned, Zend_Cache
>>> is up to the task.  There is also a PEAR package called Cache_Lite
>>> which would work to if you're interested in file based caching.
>>>
>>
>> So dreams do come true...
>>
>> Thank you for the wonderful insight.  I've been reading about the
>> memcached and Xdebug and Zend_Cache.  I've got lots to learn, but it is
>> exactly the type of material i was trying to find.
>>
>> I am not currently running an opcode cache.  I may be doing "premature
>> optimization", but i want to design the entire system intelligently from
>> the get go rather than having to rebuild later.  you know 'work smarter
>> not harder'
>>
>> Is it possible to run xdebug on a virtual host server on which i do not
>> have shell access?  I can modify php.ini via cgi, but I don't know if
>> i'd be able to view the results of xdebug on the machine.  Your opinion
>> would be appreciated.
>>
>> Thanks so much, i feel like i've just been shown a whole new world.
>> dK
>> `
>
> I still have to (fully) rtfm.  But i was wondering if the following
> scenario(s) is(are) possible.
>
> -Does memcached store the same data under different keys in the same spot?
>
> From my reading so far, i do not think so.
> My understanding is that currently memcached goes like as follows:
> key->key_hash->server->data_value
> but this approach could conceivably store the same data_value under
> different keys (thus consuming unneeded memory)
>
> What i'd like it to do is the following:
> key->key_hash->server->data_hash->server->data_value
>
> That is, each key has the data_hash as its value.  Then one uses this
> data_hash as the new key which has the data_value as its value.
> This way the only data that is replicated would be the relatively small
> data_hash, but the (larger) data itself would not be replicated.
>
> This would allow for the user to use different keys to access the same
> data.  This would be needed when seemingly different keys happen to
> share the same data, but would be too costly to recognize, predict, and
> accommodate such associations
>
> This doubles the number of calls to the server, but could conceivable
> save a great deal of memory for more cached obje

Re: [PHP] Add php.net to my browser search box

2009-07-16 Thread Eric Butera
On Thu, Jul 16, 2009 at 12:09 PM, Daniel Brown wrote:
> On Thu, Jul 16, 2009 at 11:59, Martin Scotta wrote:
>> Hi all!
>>
>> I'd like to add php.net to my browser search box.
>> Most browser can do it by "looking" at some XML provided by the site.
>
>    I had written one about two and a half years ago.  It's the
> dumbest, simplest thing, and yet it's now been downloaded over 30,000
> times.  Nuts.
>
>    If you want to use it, or just use the model as a frame to build
> your own, check it out:
>
>        http://isawit.com/php_search.php
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Check out our great hosting and dedicated server deals at
> http://twitter.com/pilotpig
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Interesting content on that site, Dan!

-- 
http://www.ericbutera.us/

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



Re: [PHP] Internal PHP caching methodology

2009-07-16 Thread Eric Butera
On Thu, Jul 16, 2009 at 5:50 PM, Daniel Kolbo wrote:
> Hello,
>
> Call me a dreamer...but I got to ask.
>
> Is there any software for helping speed up PHP by utilizing internal PHP
> caching?
>
> I am not talking about the external php cache/header control.  Smarty
> caching doesn't give me the control I need either.
>
> I would like to cache to a finer level than page by page, but rather on
> a module by module basis.  Each of my pages contains a subset of
> modules.  The content of these modules changes based upon certain
> criteria (link, time, session data, but is sometimes static across the
> site).  I would like to be able to cache individual "modules"
> (preferably based upon frequency and time to generate).
>
> I am trying to develop a way to do this, but I have to think a brighter
> mind has come before me and hopefully arrived at a solution.
>
> As always any help/thoughts are much appreciated, except for that one
> guy's comments (you all know who I am talking) ~ jk ;)
>
> Thanks,
> `
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Have you actually profiled your code to see where the pain points are
vs saying 'module?'  Are you also running an opcode cache?  From there
you can use data, block, or full page caching.  Finally you can figure
out if you want to store it in flat files or memory.  I'd start by
knowing what is actually the slow part using Xdebug and nail a few
down.

There is no end all solution.  Some pages really don't have a lot
going on and are hardly updated so full page is fine.  Others might
have something that is hard to generate on a sidebar, so block caching
would be more suitable for that.  As previously mentioned, Zend_Cache
is up to the task.  There is also a PEAR package called Cache_Lite
which would work to if you're interested in file based caching.

-- 
http://www.ericbutera.us/

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



Re: [PHP] Inverting a dependency list

2009-07-16 Thread Eric Butera
On Thu, Jul 16, 2009 at 12:09 PM, Bob McConnell wrote:
> I recall, years ago, having a set of utilities that would build a call
> tree from application code written in C. This was useful for figuring
> out dependencies in code that someone else had written. I would like to
> do something similar with a large PHP application I am now maintaining,
> but with a slightly different emphasis.
>
> This application includes several library files which contain more than
> 400 function declarations. I need to determine how many of those
> functions are actually used by the application and which can be culled
> from the code base. Is there an easy way to determine which of them are
> called somewhere and then work through the call tree to identify the
> orphans?
>
> Bob McConnell
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

PHPUnit + Xdebug has a really nice code coverage generation.  Perhaps
you could use the way phpunit hooks into xdebug to figure out likes
that get hit in the code base.  I don't know of a simple, ready-made
solution off the top of my head though.

-- 
http://www.ericbutera.us/

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



Re: [PHP] Email security

2009-07-14 Thread Eric Butera
On Tue, Jul 14, 2009 at 7:46 AM, Tiji varghese wrote:
> Hello,
>
> I've implemented a contact form on my website that would email me the 
> contents of the form and also add it to the database. Its working perfectly 
> but I'm not too sure about the security part. I don't know much about the 
> security issues concerned with email forms and the measures to check it. 
> Please help.
>
> Thanks,
> Tiji
>
>
>
>      See the Web's breaking stories, chosen by people like you. Check out 
> Yahoo! Buzz. http://in.buzz.yahoo.com/


The main thing to be aware of would be 'email header injection.'  Do
not allow returns/newlines in any of the mail header fields you
populate from user input.  Also require a valid email address and
verify that it has a valid domain name.

Next up would just be the annoyance of a client receiving tons of spam
messages.  There are a lot of automated programs crawling the web just
filling out every form it finds looking for vulns to exploit.  Even if
your form has no holes in it, the client will still get all of this
unwanted junk from the automated tests.  You can try to come up with
some clever ways of stopping that.

-- 
http://www.ericbutera.us/

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



Re: [PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Eric Butera
On Tue, Jul 14, 2009 at 6:21 AM, Anton Heuschen wrote:
> This is just a general question,
>
> I am not 100% on when to use global $var , and $this->var  and how/what
> about the GLOBAL vars 
>
> Lets say I have one file I  call config.php here I connect to the db, to
> ldap etc  the connection "var" I can then use in a file on its own ...
> obviously after I include "config.php"   lets say in config.php my DB
> connect was $dbconnect 
>
> In my index.php page I then use $dbconnect again  but do I simply use
> $dbconnect again ... or must I say global $dbconnect and then use it in the
> rest of the DB calls? or use GLOBALS .. Within a class I can use $this->var
> correct ... but its not something to be used in a basic "procedural" if I
> can call it that page...
>
>
> Lets say with my config.php and its connection to the db ...where I have
> $dbconnect .. in a class I can also use it, do I access  this var
> straight as $dbconnect or use $this->dbconnect = $dbconnect (and define it
> as global $dbconnect first before doing this)
>
> I am getting my results and seems to working most of the time, but not sure
> if I am using calls to global or $this->var ..when its not required and
> calling the var direct would of sufficed.
>
> I have never really used GLOBAL vars, so not sure how this ties in or if it
> might be even more helpful ...
>
> Some suggestions or pointers or examples would be appreciated just to clear
> up some confusion.
>
>
> Regards
>
> Oh and if one class uses methods in another class  do I instansiate a
> new object of the other class  I have seen use of OtherClass::Method
>   is this better method of $obj = new OtherClass()  use
>

You're really opening a big can of worms here, but it'll be a good
adventure.  Just keep at it and try reading some real books on the
subject.

If you include a file, all of those variables are magically in the
current scope.  So when you include config.php inside your index.php,
you can use $dbconnect directly.

Use $this-> when you are inside a class using a dynamic call on a
method or property of that class.

class Foo {
  protected $bar;
  public function __construct() {
$this->bar = 'wee';
  }
  public function setBar($value) {
$this->bar = $value;
  }
}

Inside the class you would use this-> to reference bar or call any of
that classes methods/props.  Outside you would use it like this:
$foo = new Foo;
$foo->setBar('blah');

If you haven't used globals yet, please do not feel compelled to do so
now.  There are all sorts of ways of dealing with passing around your
application state.  Globals can be used by a skilled programmer of
course, but I'd shy away from them.

I'd also recommend reading some of these pages:
http://www.php.net/manual/en/language.variables.scope.php
http://www.php.net/manual/en/language.oop5.php


Hope this helps!

-- 
http://www.ericbutera.us/

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



Re: [PHP] mysterious " f " character appearing. Why??

2009-07-09 Thread Eric Wood

Govinda wrote:


I have a mysterious "f" character  (Yes, just the letter " f " ) 
appearing in my HTML between these two seemingly benign HTMl tags:


On same computer, do a view source in other browsers too -  IE, Chrome, 
Safari etc.  F still there?  There could be a FireFox addon module 
injecting that artifact during code fix-up phase.  Run FF in safe mode 
and see if it's still there. 


-eric

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




Re: [PHP] Problems with an extension

2009-06-28 Thread Eric A. Boney
On Sunday 28 June 2009 11:00:48 you wrote:
> On Sun, Jun 28, 2009 at 10:56, Eric A.
>
> Boney wrote:
> > So I am developing a custom extension and I am having a issue. I have a
> > header file that I need included in the project. If I #include the header
> > file everything compiles and makes just fine, but after restarting the
> > web server the extension won't load.
>
> Eric,
>
> Custom extensions programming is in C/C++ (as also indicated by
> your #include reference), which is beyond the scope of this list.
> Unfortunately, there is not an official dedicated list for extensions
> developers, but if it's not urgent, you can email me privately at
> danbr...@php.net and I'll see if I can help you out.
Thanks Dan:

I thought it might be beyond this list, but I figured it might be worth the 
shot. It is not urgent at all, so I will drop you a private message with a 
more detailed explanation and if you can help great, if not, I'll keep poking 
around at it.

-Eric


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



[PHP] Problems with an extension

2009-06-28 Thread Eric A. Boney
So I am developing a custom extension and I am having a issue. I have a header 
file that I need included in the project. If I #include the header file 
everything compiles and makes just fine, but after restarting the web server 
the extension won't load.

If I remove or comment out the #include of the header file everything still 
compiles and makes just fine, and after restarting the web server the extension 
is loaded just fine.

Does anyone have any idea what would cause the extension to refuse to load 
with the header file included?

-Eric

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



  1   2   3   4   5   6   7   8   9   10   >