php-general Digest 29 Sep 2006 08:44:45 -0000 Issue 4374

Topics (messages 242378 through 242387):

Re: Changing values in .htaccess
        242378 by: Martin Marques
        242379 by: Curt Zirzow
        242381 by: Google Kreme
        242382 by: Curt Zirzow

Re: Custom Session Handler
        242380 by: Glenn Richmond

OOP Hello World
        242383 by: Martin Alterisio

Re: How do i check if a variable is a reference or a copy?
        242384 by: Mathijs

Re: strange errors from command line vs. web
        242385 by: Ivo F.A.C. Fokkema

Re: mysql_real_escape_string() question
        242386 by: Ivo F.A.C. Fokkema

Re: Best open source project/framework to support a php training course?
        242387 by: Tony Marston

Administrivia:

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

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

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
yOn Thu, 28 Sep 2006, Curt Zirzow wrote:

On 9/28/06, Martin Marques <[email protected]> wrote:
I'm trying helplessly to get session.use_trans_sid to true in one
directory that needs it. So I put this in an .htaccess file:

php_value session.use_trans_sid 1

The thing is, it didn't work. I also tried changing 1 to On with no luck
at all.

Is .htaccess enabled at all?  by default apache doesn't have it
enabled in most installations.

OK, just found this in my VirtualHost file:

AllowOverride None

If you can, set this on a per directory setting in your virtualhost
setting within a <Directory> or <Location>, instead of turning on
.htaccess.

As I have to modify it anyway, maybe I'll just put it in the virtualhost configuration file.

--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
---------------------------------------------------------
Lic. Martín Marqués         |   SELECT 'mmarques' ||
Centro de Telemática        |       '@' || 'unl.edu.ar';
Universidad Nacional        |   DBA, Programador,
    del Litoral             |   Administrador
---------------------------------------------------------

--- End Message ---
--- Begin Message ---
On 9/28/06, Martin Marques <[email protected]> wrote:
yOn Thu, 28 Sep 2006, Curt Zirzow wrote:

> On 9/28/06, Martin Marques <[email protected]> wrote:
>> I'm trying helplessly to get session.use_trans_sid to true in one
>> directory that needs it. So I put this in an .htaccess file:
>>
>> php_value session.use_trans_sid 1
>>
>> The thing is, it didn't work. I also tried changing 1 to On with no luck
>> at all.
>
> Is .htaccess enabled at all?  by default apache doesn't have it
> enabled in most installations.

OK, just found this in my VirtualHost file:

AllowOverride None

> If you can, set this on a per directory setting in your virtualhost
> setting within a <Directory> or <Location>, instead of turning on
> .htaccess.

As I have to modify it anyway, maybe I'll just put it in the virtualhost
configuration file.

Yeah, it is wise to do that, enabling .htaccess is not the best of ideas.

Just for a brief reason why.. condsider a page request of:
 http://yourserver/some/dir/path/file.php

apache has to check recursivly down the path to / for .htaccess before
the request can be handled; that is a lot of overhead in my opinion
and is a key point as why it is disabled by default.

Curt.

--- End Message ---
--- Begin Message ---
On 28 Sep 2006, at 14:30 , Curt Zirzow wrote:
If you can, set this on a per directory setting in your virtualhost
setting within a <Directory> or <Location>, instead of turning on
.htaccess.

Er... why?  So you have to get root privs to edit your virtual conf?

there's nothing wrong with .htaccess, just a lot of people get confused and screw things up.

.htacess is very useful.

--
Look, that's why there's rules, understand? So that you *think* before you break 'em.
--- End Message ---
--- Begin Message ---
On 9/28/06, Google Kreme <[EMAIL PROTECTED]> wrote:
On 28 Sep 2006, at 14:30 , Curt Zirzow wrote:
> If you can, set this on a per directory setting in your virtualhost
> setting within a <Directory> or <Location>, instead of turning on
> .htaccess.

Er... why?  So you have to get root privs to edit your virtual conf?

You dont need to have root, just the proper privs to modify the
paticular virtual conf file.



there's nothing wrong with .htaccess, just a lot of people get
confused and screw things up.

There are a lot of things wrong with .htacces, but this would be more
of a topic on an apache list than here.


.htacess is very useful.

As i mentioned using .htaccess should be your last resort; there is a
big performance hit with using .htaccess and if you have the ability
dont use it and turn it off if you arn't using it.

Curt.

--- End Message ---
--- Begin Message ---
Hi Richard,

No suggestions yet, but hopefully something will come through. Wouldn't
you know it, I had a brainstorm while writing this response.  amazing
what a night's sleep will do. The key to getting a module registered is
in session.c in the function PHPAPI int
php_session_register_module(ps_module *ptr). Obvious now, isn't it :)

As for open sourcing it, that call's up to my employer, but it may
actually be a requirement (not that familiar with the license on php
source). Anyway, they're fairly pro-open souce, so it's likely that
it'll get released back into the source tree. I'd say the biggest
benefit from my point of view is not having to re-merge the changes in
for every release of PHP :)

Who do I talk to about becoming a developer on the php source?

Cheers,

Glenn.

Richard Lynch wrote:
> On Thu, September 28, 2006 1:46 am, Glenn Richmond wrote:
>   
>> I couldn't find a developers list, so I hope this is the right list to
>>     
>
> If you get no answer here, php-internals is a potential source, for a
> quick reference to the right part of the source where that bit of code
> lives.
>
> Also try finding it for yourself in the source, or http://lxr.php.net
>
> Good Luck -- It would certainly be very cool to have this extension
> OpenSourced and added to PECL.  Hint, hint.
>
> Note that OpenSourcing it and adding it to PECL might get another
> developer interested in fixing your current problem, too, so it's a
> win for you.
>
>   

--- End Message ---
--- Begin Message ---
What's up folks?

I just wanted to tell you about a thread that's going on in the spanish php
mailing list. A fellow software developer which had just started with OOP
was asking for "Hello World" examples using OOP. The examples of code he had
been doing was not that different from the usual Hello World example we all
know and love(?), so I thought he was missing the point of what was the
purpose of using OOP. This was my reply (I'll try to keep the translation as
accurate as possible):

I believe you have misunderstood what is the purpose of OOP, your objects
are not proper abstractions.

First and most important, you should define what is the problem to solve:
greet the world.
We build an abstraction of the problem and its main components: somebody who
greets and something to greet.
Here we're working with generalizations, since our main objective is to
build reusable objects. For that purpose is useful that our "saluter" could
be used to greet more than just the world.

Therefore we'll first define what kind of interaction we expect the
salutation receivers to have, in the following interface:

 interface Salutable {
   public function getSalutationName();
 }

In this interface we have all we need to properly greet any entity: the name
we should use when doing the salutation.

Then we create the object which represents the world:

 class World implements Salutable {
   public function getSalutationName() {
     return "World";
   }
 }

Now we're missing a saluter, but we're not sure which way of greeting would
be appropiate, so we prefer to create an abstract saluter and leave the
child implementation to decide the appropiate greeting:

 abstract class Saluter {
   abstract public function greet(Salutable $receiver);
 }

In our case we need a formal saluter as we should not disrespect the world
(saying "hey! wazzup world?" could be offensive), then:

 class FormalSaluter extends Saluter {
   public function greet(Salutable $receiver) {
     echo "Hello " . $receiver->getSalutationName() . "\n";
   }
 }

Finally we make our saluter greet the world:

 $saluter = new FormalSaluter();
 $world = new World();
 $saluter->greet($world);

----

Other things you should keep in mind:

* PHP's type hinting is preety limited, in this case we would like to
indicate that the name should be provided as a string but we can't. Maybe it
would be useful to use an object as a wrapper for native strings. EDIT: I
remembered while translating this that type hinting can only be used in
function parameters, therefore this point is useless.

* En this model it seems more appropiate that the saluter is an abstract
class, since salutation works one way, but, in the event salutations became
a two way trip, an interface would be more appropiate for the saluters.

* Here we're sending the salutation to the standard output, which is
acceptable in this case, but a more complex abstration would require us to
indicate where we should procede with the salutation, and we will have to
provide an abstraction for the possible salutation enviroments.

* A factory of saluters would be a nice feature.

------------

That's it. If you find this interesting I'll try to keep up with the
translation of following posts.

--- End Message ---
--- Begin Message ---
Martin Alterisio wrote:
2006/9/28, Mathijs <[EMAIL PROTECTED]>:

Hello there,

Is there a way to check if a variable is passed by reference or if it is
just a copy. With something like is_copy or is_reference?

Thx in advance.


Is this part of the "I don't know if two vars reference the same object in
PHP4" dilemma?

Well it isn't realy my problem, but a colluage of mine.
Also it is PHP5.

But as i understand, there isn't a way to check what kind of variable it is.
Think he just needs to use a debugger then.

--- End Message ---
--- Begin Message ---
On Thu, 28 Sep 2006 14:29:13 -0400, blackwater dev wrote:

> Yep, I get called to undefined function so I need to somehow re-compile the
> cli version?  How do I give support to just the cli version?  I'm going to
> the docs now.
> 
> Thanks!

I guess it's dependent on your OS, but you might be able to just enable
this line in your php.ini file for the cli version:

extension=mysql.so

Your php.ini file may be found in

/etc/php4/cli/php.ini

That's where mine (PHP4) is, but it's dependent on your specific distro.
Are you on a "package type" of distro, such as Debian, Ubuntu, Fedora,
Suse or the like? Or are you compiling stuff like on Gentoo?

Ivo

--- End Message ---
--- Begin Message ---
On Thu, 28 Sep 2006 11:33:06 -0400, Eric Butera wrote:

> On 9/28/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote:
>>
>> Hi Tedd,
>>
>> According to
>> http://nl3.php.net/mysql_real_escape_string
>>
>> The function requires a MySQL connection. If there is none, it
>> will try and create one. That fails now. Possibly you could use addslashes()?
>>
>> Regards,
>>
>> Ivo
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> Don't use addslashes.  Keep using mysql_real_escape string  but make
> sure you have a valid link identifier like Ivo said.
> 
> string mysql_real_escape_string ( string unescaped_string [, resource
> link_identifier] )

He's not actually *putting* it in a database, so isn't it useless to use a
mysql_ function for this...? Maybe I misunderstand Tedd and he does use a
database, as I don't see why he would need mysql_real_escape_string() for
cleaning input...

--- End Message ---
--- Begin Message ---
""Pinocchio007"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Thanks.
>
> Is any open source project using your framework? I couldn't find this
> information on your website.

Not at present. It is being used on a closed source project for a commercial 
customer which may result in a commercial application in the near future. It 
works with both PHP 4 and 5, the "old" and the "new" MySQL extensions, it 
aso supports PostgreSQL. It uses a data dictionary to generate all table 
classes, has built-in audit logging and workflow. The main advantage is that 
you can generate web applications without writing any HTML or SQL.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

>
> ""Tony Marston"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> If you want a web application framework that your students can play with
> may
>> I suggest http://www.radicore.org  This is already being used as a
> training
>> aid by a university in the far east, so it must have some merit.
>>
>> -- 
>> Tony Marston
>> http://www.tonymarston.net
>> http://www.radicore.org
>>
>> ""Pinocchio007"" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> >I am in charge of outlining a PHP/mySQL course (intro and advanced) for
> an
>> > education institute. I would like to include in the course program an
>> > in-depth study of an existing open-source project, allowing the 
>> > students
>> > to
>> > be confronted, from an early stage, to a real-world environment. My
>> > problem
>> > is simple: which project/framework to choose in order to bring the
> current
>> > "best practice" to our students, and prepare them for the future. Not
>> > being
>> > a professional PHP developer myself, I would appreciate any
>> > recommendation.
>> > Which OS project would you include? Which framework? And why?
>> >
>> > My first idea was "osCommerce", then somebody recommended "Typo3",
>> > followed
>> > by a "go for Joomla". Well, I am hesitating.
>> > Anybody can recommend an article/paper comparing the different PHP
>> > frameworks/application architectures?
>> > Is there a list where such topics are discussed?
>> >
>> > Thanks for your help and recommendations. 

--- End Message ---

Reply via email to