[PHP] fsockopen with ADH cipher

2010-08-20 Thread Dave Cundiff
Hello,

I've scoured the net and it appears I may be out of luck.

Is it possible to change the cipher fsockopen uses for SSL? I have a
remote socket that uses ADH which I can connect to fine with the
openssl client.

CONNECTED(0003)
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 298 bytes and written 201 bytes
---
New, TLSv1/SSLv3, Cipher is ADH-AES256-SHA
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol  : TLSv1
Cipher: ADH-AES256-SHA
Session-ID: 2163F431CC23523B8F156F6C2E806F3CA23B7F9149E92A2E3F80FEE420F72E4F
Session-ID-ctx:
Master-Key:
ECC5BB2D5B2F76B6D6F332FCEE294C21B0FFAF3C93322F2CD82FF9AFAFC6B6DD3EA371F0F1ADA09FB00B046BC1DB1D59
Key-Arg   : None
Krb5 Principal: None
Start Time: 1282349024
Timeout   : 300 (sec)
Verify return code: 0 (ok)
---


However, my simple PHP script fails.



[r...@host ~]# php ssltest.php
PHP Warning:  fsockopen(): SSL operation failed with code 1. OpenSSL
Error messages:
error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake
failure in /root/ssltest.php on line 2
PHP Warning:  fsockopen(): Failed to enable crypto in
/root/ssltest.php on line 2
PHP Warning:  fsockopen(): unable to connect to
tls://host.domain.com:5666 (Unknown error) in /root/ssltest.php on
line 2

I had to specify ADH on the cipher list for OpenSSL to be able to make
the connection but cannot find a way to do so for fsockopen. Can a
cipher even be specified?

Thanks,
-- 
Dave Cundiff
System Administrator
A2Hosting, Inc
http://www.a2hosting.com

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



[PHP] Re: [PHP-DEV] Re: [PHP] mod_php

2010-08-20 Thread Guillaume Rossolini
Hi,

1. What optimizations does PHP interpreter make? I guess it should be
> able to check file modification time and cease to compile it again and
> again. Is this correct?
>
> There is some bytecode form, right?
>

Core PHP does not optimize your code like a DBMS would rewrite your SQL.
There are however extensions that can do that kind of post processing (APC,
XCache, etc.).


> What else does it do? For instance if there is a big, immutable class in
> the application (say it contains a bunch of constant XML documents,
> hardcoded into the source): will the interpreter notice that and
> instantiate this class only once across multiple requests?
>
> What if this class generates side effects (like printing "hello world"
> in the constructor) and what if it doesn't?
>

Fortunately, it does not notice that. Remember that PHP is a dynamic
language by nature and that, given the right extension(s), even class
definitions can be altered at runtime. It would be a mess to use those
functionalities if PHP itself compiled the code.


> 2. I guess PHP application wide cache is quite a different story? For
> the worker processes are separate... Or maybe PHP interpreter itself
> provides any means for that??
>

Yes, it is a different story indeed. Often, application wide caches are
application specific, and not only their configuration.There is userland
code for this on the Web. Basically, that's the kind of functionality
frameworks provide, so by choosing a framework you get their caching
techniques. Depending on the application, you could rely on your web server
(httpd or whatever) to do that. Of course, you could also use output caching
with PHP (look for ob_start in the manual).


> 3. Does PHP interpreter maintain any state across different requests
> within the context of a single Apache worker process? If so, what does
> this state contain?
>

I would suggest you read the "sessions" section of the manual or that you
split your questions to php-general and internals. The internals list is not
suited for this discussion.

4. Does PHP interpreter maintain any global state within the context of
> a single Apache HTTP server instance? If so, what does this state contain?


I don't think there is such a state ready for userland code to read, but I
also don't think you really need it. You can read a few things like the
total memory usage for your script, as well as some apache-related functions
(quite well documented, feel free to read the docs) and that's about it.
That's more than most web applications need (production-wise), at any rate.


> 5. What about system wide PHP interpreter state?...
>

PHP depends on a SAPI, it is not hosted directly by the system. Its memory
is part of the memory allocated to the server. When a segfault happens, I
guess it kills both the script and the thread running it, then the server
spawns another thread running PHP and life goes on. The logs have what you
need.


> 6. I heard some nasty rumors that PHP interpreter resource management is
> somewhat problematic (memory leaks, or something), and because of that
> those Apache worker processes have to be killed from time to time.
>

PHP is dynamically typed. From a memory perspective, it is a language with
kind of managed types (my choice of words may not be optimal here). It even
comes with a garbage collector from 5.3 onwards though memory management a
la C is not what PHP is used for. But yes, if you abuse the easy variable
declaring and copying PHP provides, you will end up eating your memory as
you would with anything else. You could kill processes or use a CGI-derived
SAPI. Apache httpd is not the only web server out there. Most of the time,
memory leaks that make you restart apache workers are application-level
leaks, not PHP's fault. When found, memory leaks in PHP are bugs and bugs
get fixed, so in the long run there are no more memory leaks in PHP than in
other systems. Again, internals is not suited for this talk unless you have
a very specific patch or RFC to discuss.

Regards,

--
Guillaume Rossolini


[PHP] error_log file error reporting level

2010-08-20 Thread hovnocuc

Hello,

[ Question ]
How do I force error_log to log only errors specified in the 
error_reporting directive? Is it even possible or did I get something wrong?
I have one old script which uses ereg and the awesome size of the error 
log is getting on my nerves.


[ Current ini config ]
error_reporting = E_ALL & ~E_DEPRECATED  ;;or E_ALL ^ E_DEPRECATED
display_errors = Off
log_errors = On
error_log = /var/log/php-fpm/php-errors.log

[ PHP ]
5.3.3 + suhosin patch 5.3.3-0.9.10 + suhosin extension 0.9.32.1
pecl: imagick-3.0.1RC1, APC-3.1.3p1, geoip-1.0.7, rar-2.0.0
php configure: in the appendix

[ Expected result ]
php-errors.log containing all errors EXCEPT deprecated notices

[ Actual result ]

 PHP Deprecated:  Function ereg() is deprecated in ...


[ Notes ]
I know which ini php loads, so yeah.. I'm actually using the same that 
I'm configuring.

I'm not using syslog, but a file. See Current ini config above.


Thank you for your time.

[ Appendix ]
../configure --prefix=/usr --enable-fpm --disable-rpath --with-pear 
--disable-debug --with-openssl --with-pcre-regex --with-zlib 
--enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif 
--enable-inline-optimization --with-gd --with-jpeg-dir --with-png-dir 
--with-freetype-dir --with-gettext --with-imap --with-imap-ssl 
--with-kerberos --enable-mbstring --enable-mbregex --with-mcrypt 
--with-mysql --with-mysqli --enable-pdo --with-pdo-mysql 
--with-pdo-pgsql --with-pgsql --enable-shmop --enable-soap 
--enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem 
--enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-xsl 
--enable-zip --enable-ftp --enable-dom --enable-xmlwriter 
--enable-xmlreader --enable-tokenizer --enable-simplexml 
--enable-session --enable-posix --enable-phar --enable-libxml 
--enable-json --with-iconv --enable-filter --enable-fileinfo --enable-ctype


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



Re: [PHP] Fatal error: Call to undefined method

2010-08-20 Thread Jo�o C�ndido de Souza Neto
Try this:

 escreveu na mensagem 
news:29494740.p...@talk.nabble.com...
>
> Greetings,
>
> I'm having a very simple problem that I can't seem to find the solution 
> to.
> I try and access a method in this class I made called
> MyPropertyManagement... the method is named get_complexes().  I try and
> strip down the entire class to just focus on this problem with the hopes 
> of
> it making things simple enough that the error will become apparent, but
> unfortunately it has not.  I am able to make a new instances of this 
> class,
> add in some other methods and run/use them just fine.  For some reason 
> this
> method keeps erroring out saying it is undefined.  I don't understand why?
> Can someone please shed some light on this subject please?
>
> The error is: "Fatal error: Call to undefined method
> PropertyMgmt::get_complexes() in /usr/www/test/test2.php on line 6"
>
> The files are as follows:
>
> /*** /usr/www/test/inc/class/PropertyManagement.class.php
> ***/
>
>
> 
> class PropertyMgmt
> {
>function PropertyMgmt() {
>global $complexes;   /* yes I know using globals is dangerous, I
> will fix this soon! :-) */
>}
>
>
>
>
>   public function PropertyMgmt::get_complexes() {
> /* null */
>   }
>
> } // end class
>
>
>
>
>
> /*** /usr/www/test/test2.php ***/
>  require_once('/usr/www/test/inc/class/PropertyMgmt.class.php');
>
>
> $PM = new PropertyMgmt();
> $PM->get_complexes();
>
> die();
>
> /* end test2.php /
>
> Thank you in advance...
>
> -
> ___
> PHP 5.3.3
> Apache 1.3.37
> MySQL 5.0.24a
> FreeBSD 6.2-PRERELEASE
> -- 
> View this message in context: 
> http://old.nabble.com/Fatal-error%3A-Call-to-undefined-method-tp29494740p29494740.html
> Sent from the PHP - General mailing list archive at Nabble.com.
> 



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



[PHP] Fatal error: Call to undefined method

2010-08-20 Thread TransientSeeker

Greetings,

I'm having a very simple problem that I can't seem to find the solution to. 
I try and access a method in this class I made called
MyPropertyManagement... the method is named get_complexes().  I try and
strip down the entire class to just focus on this problem with the hopes of
it making things simple enough that the error will become apparent, but
unfortunately it has not.  I am able to make a new instances of this class,
add in some other methods and run/use them just fine.  For some reason this
method keeps erroring out saying it is undefined.  I don't understand why? 
Can someone please shed some light on this subject please?

The error is: "Fatal error: Call to undefined method
PropertyMgmt::get_complexes() in /usr/www/test/test2.php on line 6"

The files are as follows:

/*** /usr/www/test/inc/class/PropertyManagement.class.php
***/


get_complexes();

die();

/* end test2.php /

Thank you in advance...

-
___
PHP 5.3.3
Apache 1.3.37
MySQL 5.0.24a
FreeBSD 6.2-PRERELEASE
-- 
View this message in context: 
http://old.nabble.com/Fatal-error%3A-Call-to-undefined-method-tp29494740p29494740.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] mod_php

2010-08-20 Thread Stanisław Findeisen
On 2010-08-20 17:10, Bostjan Skufca wrote:
> Yes, this is correct.
> 
> If you look at sapi/apache2handler/sapi_apache2.c in PHP sources, you will
> find that PHP SAPI registers it's function php_handler() within apache. This
> function gets called every time PHP is requested by some client (with
> appropriate configuration, of course).
> 
> I must admit that PHP-DEV (INTERNALS) seems more appropriate list for such
> question :)

1. What optimizations does PHP interpreter make? I guess it should be
able to check file modification time and cease to compile it again and
again. Is this correct?

There is some bytecode form, right?

What else does it do? For instance if there is a big, immutable class in
the application (say it contains a bunch of constant XML documents,
hardcoded into the source): will the interpreter notice that and
instantiate this class only once across multiple requests?

What if this class generates side effects (like printing "hello world"
in the constructor) and what if it doesn't?

2. I guess PHP application wide cache is quite a different story? For
the worker processes are separate... Or maybe PHP interpreter itself
provides any means for that??

3. Does PHP interpreter maintain any state across different requests
within the context of a single Apache worker process? If so, what does
this state contain?

4. Does PHP interpreter maintain any global state within the context of
a single Apache HTTP server instance? If so, what does this state contain?

5. What about system wide PHP interpreter state?...

6. I heard some nasty rumors that PHP interpreter resource management is
somewhat problematic (memory leaks, or something), and because of that
those Apache worker processes have to be killed from time to time.

Could you please comment on this?

> 2010/8/20 Stanisław Findeisen 
> 
>> Hi
>>
>> Could anyone please explain to me the basic architecture of PHP module
>> when running "in process" within Apache HTTP server?
>> I guess this is called "mod_php".
>>
>> As far as I understand the shared library (e.g., libphp5.so) is being
>> dynamically loaded by an Apache working process and then, whenever a
>> .php (or .php3, or...) file is requested the working process calls the
>> PHP interpreter. This call to the PHP interpreter is a function call and
>> there is no fork(2) nor execve(2) in play at all.
>>
>> Is this correct?

STF

http://eisenbits.homelinux.net/~stf/
OpenPGP: DFD9 0146 3794 9CF6 17EA  D63F DBF5 8AA8 3B31 FE8A

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



[PHP] add function to solr extension

2010-08-20 Thread Thomas Gambier
Hi,

 

Can i have some help to create a class to add a function to solr extension ?

I want to make a function which send me back the number of results of a
query...

(field NumFound of array return of SolrResponse::getResponse())

 

Here is the link to the extension :
http://www.php.net/manual/fr/book.solr.php

 

I didn't know how to do. Create or extend a class ? Which one ? How ?

 

Can i have some help to get started please.

 

Thanks by advance.

 

Regards

 

Thomas

 

 



Re: [PHP] Bitwise NOT operator?

2010-08-20 Thread Andy McKenzie
  Thanks to everyone who responded.  I've dealt with binary math
before, but it never occurred to me (and doesn't seem to be anywhere
in the document page at php.net!) that it would automatically pad the
number I entered.

  The example I gave was essentially a test I was running:  in the
real script, I'm trying to calculate the number of IP addresses in a
given subnet, and I was getting some seriously weird results.  I'm
still not entirely sure what's going on, but this should help.

Thanks again!
-Alex


On Fri, Aug 20, 2010 at 11:42 AM, Peter Lind  wrote:
> On 20 August 2010 17:41, Peter Lind  wrote:
>> On 20 August 2010 17:10, Andy McKenzie  wrote:
>>> Hey everyone,
>>>
>>>  I'm really not sure what's going on here:  basically, the bitwise
>>> NOT operator seems to simply not work.  Here's an example of what I
>>> see.
>>>
>>> Script
>>>
>>> $ cat bintest2.php
>>>
>>> >>
>>> $bin = 2;
>>> $notbin = ~$bin;
>>>
>>> echo "Bin: " . decbin($bin) . "  !bin:  " . decbin($notbin) . "\n";
>>> echo "Bin: $bin  !bin:  $notbin\n";
>>>
>>>
>>> ?>
>>> =
>>>
>>>
>>> Output
>>>
>>> $ php bintest2.php
>>> Bin: 10  !bin:  1101
>>> Bin: 2  !bin:  -3
>>>
>>> =
>>>
>>>
>>> Obviously that's not the expected response.  I expect to get something
>>> more like this:
>>>
>>> Bin: 10  !bin:  01
>>> Bin: 2  !bin:  1
>>>
>>>
>>> Can anyone shed some light on this for me?  The server is running an
>>> old version of OpenSUSE, and php --version returns:
>>>
>>
>> You probably need to read up on computer architechture and CS theory -
>> the ~ operator works fine, your understanding does not. What you're
>> looking at is the following:
>>
>> $bin = 2 = 0010 (64 bit number)
>
> 32-bit number, as Colin pointed out.
>
> Peter
>
> --
> 
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> BeWelcome/Couchsurfing: Fake51
> Twitter: http://twitter.com/kafe15
> 
>

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



[PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Colin Guthrie
'Twas brillig, and Andrew Ballard at 20/08/10 15:55 did gyre and gimble:
> On Fri, Aug 20, 2010 at 10:19 AM, Colin Guthrie  wrote:
>> The customer is always right -> in his own mind (even if not in his RIGHT 
>> mind) <- after all!
> 
> Corrected that for you.  ;-)

:D

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Bitwise NOT operator?

2010-08-20 Thread Peter Lind
On 20 August 2010 17:41, Peter Lind  wrote:
> On 20 August 2010 17:10, Andy McKenzie  wrote:
>> Hey everyone,
>>
>>  I'm really not sure what's going on here:  basically, the bitwise
>> NOT operator seems to simply not work.  Here's an example of what I
>> see.
>>
>> Script
>>
>> $ cat bintest2.php
>>
>> >
>> $bin = 2;
>> $notbin = ~$bin;
>>
>> echo "Bin: " . decbin($bin) . "  !bin:  " . decbin($notbin) . "\n";
>> echo "Bin: $bin  !bin:  $notbin\n";
>>
>>
>> ?>
>> =
>>
>>
>> Output
>>
>> $ php bintest2.php
>> Bin: 10  !bin:  1101
>> Bin: 2  !bin:  -3
>>
>> =
>>
>>
>> Obviously that's not the expected response.  I expect to get something
>> more like this:
>>
>> Bin: 10  !bin:  01
>> Bin: 2  !bin:  1
>>
>>
>> Can anyone shed some light on this for me?  The server is running an
>> old version of OpenSUSE, and php --version returns:
>>
>
> You probably need to read up on computer architechture and CS theory -
> the ~ operator works fine, your understanding does not. What you're
> looking at is the following:
>
> $bin = 2 = 0010 (64 bit number)

32-bit number, as Colin pointed out.

Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] Bitwise NOT operator?

2010-08-20 Thread Peter Lind
On 20 August 2010 17:10, Andy McKenzie  wrote:
> Hey everyone,
>
>  I'm really not sure what's going on here:  basically, the bitwise
> NOT operator seems to simply not work.  Here's an example of what I
> see.
>
> Script
>
> $ cat bintest2.php
>
> 
> $bin = 2;
> $notbin = ~$bin;
>
> echo "Bin: " . decbin($bin) . "  !bin:  " . decbin($notbin) . "\n";
> echo "Bin: $bin  !bin:  $notbin\n";
>
>
> ?>
> =
>
>
> Output
>
> $ php bintest2.php
> Bin: 10  !bin:  1101
> Bin: 2  !bin:  -3
>
> =
>
>
> Obviously that's not the expected response.  I expect to get something
> more like this:
>
> Bin: 10  !bin:  01
> Bin: 2  !bin:  1
>
>
> Can anyone shed some light on this for me?  The server is running an
> old version of OpenSUSE, and php --version returns:
>

You probably need to read up on computer architechture and CS theory -
the ~ operator works fine, your understanding does not. What you're
looking at is the following:

$bin = 2 = 0010 (64 bit number)
~$bin = ~2 = -3 = 1101 (the inverse of the above)

Computers generally do not operate on a couple of bits from a byte -
they tend to operate on a byte, a word, a doubleword, etc (before any
nitpickers interrupt: sure, they can, but most operations don't).
Hence, you're not doing a not operation on just "10", you're doing it
on "0010". And as you are operating on a
signed int, you'll get a negative number out of the ~ operation
(seeing as you flipped the most significant bit).

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



[PHP] Re: Bitwise NOT operator?

2010-08-20 Thread Colin Guthrie
'Twas brillig, and Andy McKenzie at 20/08/10 16:10 did gyre and gimble:
> Hey everyone,
> 
>   I'm really not sure what's going on here:  basically, the bitwise
> NOT operator seems to simply not work.  Here's an example of what I
> see.
> 
> Script
> 
> $ cat bintest2.php
> 
>  
> $bin = 2;
> $notbin = ~$bin;
> 
> echo "Bin: " . decbin($bin) . "  !bin:  " . decbin($notbin) . "\n";
> echo "Bin: $bin  !bin:  $notbin\n";
> 
> 
> ?>
> =
> 
> 
> Output
> 
> $ php bintest2.php
> Bin: 10  !bin:  1101
> Bin: 2  !bin:  -3
> 
> =
> 
> 
> Obviously that's not the expected response.  I expect to get something
> more like this:
> 
> Bin: 10  !bin:  01
> Bin: 2  !bin:  1
> 
> 
> Can anyone shed some light on this for me?  


The output looks correct to me, so I think it's your expectations that
are incorrect.

You are assuming that you are working with a 2-bit number the in actual
fact you are working with a 32-bit number.

If you did

$bin = 2;
$notbin = ~$bin & 3;

Then this should get the results you want. The bitwise & 3 bit
essentially limits things to a 2-bit number. (3 in binary is represented
by 1's for the two LSBs and 0's for all other bits).

FWIW, the fact that ~2 == -3 is due to twos compliment binary notation:
http://en.wikipedia.org/wiki/Twos_Compliment

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



[PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Colin Guthrie
'Twas brillig, and Ashley Sheridan at 20/08/10 15:29 did gyre and gimble:
> If you use a sitemap specific to a search engine (Google sitemap for
> example) then you can specify how often a page changes, or tell it not
> to index at all. This could help a little in preventing getting
> penalised by a search engine for the indexed content never matching what
> a user actually does see. 

Yeah we do that already (partly to reduce being hammered by bots, but
also because there is no point in indexing too oftent!)

> It brings to mind what a lot of companies do to ensure they are popular
> in the phonebook. Ever noticed how there are an unusually high number of
> companies towards the extreme ends of the alphabet. It was a deliberate
> ploy to get as near to the first or last listing in a phonebook, which
> was always done alphabetically (with the exception of paid-for listings
> which were usually as larger adverts alongside the regular listings) So
> you end up with AAA Cars, AA Electricians, ZZ Plumbers, ZYX Mechanics,
> etc.

Yeah this was a problem for us a few years ago and we had to actually
disable users from editing their own "thing" names for some clients.
This allowed our clients to keep a solid control over it and make sure
that the name were relevant and accurate!

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] mod_php

2010-08-20 Thread Bostjan Skufca
Yes, this is correct.

If you look at sapi/apache2handler/sapi_apache2.c in PHP sources, you will
find that PHP SAPI registers it's function php_handler() within apache. This
function gets called every time PHP is requested by some client (with
appropriate configuration, of course).

I must admit that PHP-DEV (INTERNALS) seems more appropriate list for such
question :)

b.


2010/8/20 Stanisław Findeisen 

> Hi
>
> Could anyone please explain to me the basic architecture of PHP module
> when running "in process" within Apache HTTP server?
> I guess this is called "mod_php".
>
> As far as I understand the shared library (e.g., libphp5.so) is being
> dynamically loaded by an Apache working process and then, whenever a
> .php (or .php3, or...) file is requested the working process calls the
> PHP interpreter. This call to the PHP interpreter is a function call and
> there is no fork(2) nor execve(2) in play at all.
>
> Is this correct?
>
> STF
>
> http://eisenbits.homelinux.net/~stf/
> OpenPGP: DFD9 0146 3794 9CF6 17EA  D63F DBF5 8AA8 3B31 FE8A
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Bitwise NOT operator?

2010-08-20 Thread Andy McKenzie
Hey everyone,

  I'm really not sure what's going on here:  basically, the bitwise
NOT operator seems to simply not work.  Here's an example of what I
see.

Script

$ cat bintest2.php


=


Output

$ php bintest2.php
Bin: 10  !bin:  1101
Bin: 2  !bin:  -3

=


Obviously that's not the expected response.  I expect to get something
more like this:

Bin: 10  !bin:  01
Bin: 2  !bin:  1


Can anyone shed some light on this for me?  The server is running an
old version of OpenSUSE, and php --version returns:

PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Dec 12 2007 03:51:56)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies


I get the same response on an Ubuntu 8.04 LTS server with PHP
5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2.

Thanks in advance,

  Alex McKenzie
  amckenz...@gmail.com

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



Re: [PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Andrew Ballard
On Fri, Aug 20, 2010 at 10:19 AM, Colin Guthrie  wrote:
> The customer is always right -> in his own mind (even if not in his RIGHT 
> mind) <- after all!

Corrected that for you.  ;-)

Andrew

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



Re: [PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Ashley Sheridan
On Fri, 2010-08-20 at 15:19 +0100, Colin Guthrie wrote:

> 'Twas brillig, and Andrew Ballard at 20/08/10 15:04 did gyre and gimble:
> > On Fri, Aug 20, 2010 at 9:31 AM, Colin Guthrie  wrote:
> >> Speaking of SEO, that was one of our concerns about randomising listings
> >> too. What impact do you think such randomised listings will have on SEO?
> >>
> >> Obviously if a term is matched for a listing page that contains a thing
> >> and when the user visits that page, the thing itself is not on in the
> >> listing, then the user will be disappointed, but will this actually
> >> result in SEO penalties?
> >>
> >> Col
> > 
> > I'm not sure it would penalize you in the algorithms. I was thinking
> > more of the number of times I have followed a promising-looking link
> > and found that the site where I was directed was a page of and index
> > of article headings or post subjects showing results 1000-1500 out of
> > 1+, and the item I was hoping to see is no longer on that page. Is
> > it on the next page? No. Next page? No. Oh, forget it - back go
> > [search engine].
> > 
> > In that case, even if the site's page rank doesn't decrease, the
> > search results are out-of-sync and thus inaccurate. The site can
> > definitely take a hit with regard to end-user perception and can cause
> > annoyed users to leave and/or ignore your site, which are more
> > important issues than a number from some search engine's algorithm.
> > After all, it doesn't matter how many people Google, Bing, Yahoo or
> > some other search engine sends your way if those users end up
> > frustrated by the experience and don't actually use the site once they
> > get there.
> 
> Yeah, these are also my concerns with the approach and we've been
> careful to point them out to our client. If they know the potential
> risks and they still want to go ahead then we've just got to live with
> it, even if we don't agree that it's the right solution. The customer is
> always right after all!
> 
> Cheers for the comments :)
> 
> Col
> 
> -- 
> 
> Colin Guthrie
> gmane(at)colin.guthr.ie
> http://colin.guthr.ie/
> 
> Day Job:
>   Tribalogic Limited [http://www.tribalogic.net/]
> Open Source:
>   Mandriva Linux Contributor [http://www.mandriva.com/]
>   PulseAudio Hacker [http://www.pulseaudio.org/]
>   Trac Hacker [http://trac.edgewall.org/]
> 
> 


If you use a sitemap specific to a search engine (Google sitemap for
example) then you can specify how often a page changes, or tell it not
to index at all. This could help a little in preventing getting
penalised by a search engine for the indexed content never matching what
a user actually does see. I have actually reported sites myself where I
was given something completely different from what I saw on a serp
listing, although I'm talking about wildly different, not just a product
or blog post that's been pushed back a few pages!

It brings to mind what a lot of companies do to ensure they are popular
in the phonebook. Ever noticed how there are an unusually high number of
companies towards the extreme ends of the alphabet. It was a deliberate
ploy to get as near to the first or last listing in a phonebook, which
was always done alphabetically (with the exception of paid-for listings
which were usually as larger adverts alongside the regular listings) So
you end up with AAA Cars, AA Electricians, ZZ Plumbers, ZYX Mechanics,
etc.

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




[PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Colin Guthrie
'Twas brillig, and Andrew Ballard at 20/08/10 15:04 did gyre and gimble:
> On Fri, Aug 20, 2010 at 9:31 AM, Colin Guthrie  wrote:
>> Speaking of SEO, that was one of our concerns about randomising listings
>> too. What impact do you think such randomised listings will have on SEO?
>>
>> Obviously if a term is matched for a listing page that contains a thing
>> and when the user visits that page, the thing itself is not on in the
>> listing, then the user will be disappointed, but will this actually
>> result in SEO penalties?
>>
>> Col
> 
> I'm not sure it would penalize you in the algorithms. I was thinking
> more of the number of times I have followed a promising-looking link
> and found that the site where I was directed was a page of and index
> of article headings or post subjects showing results 1000-1500 out of
> 1+, and the item I was hoping to see is no longer on that page. Is
> it on the next page? No. Next page? No. Oh, forget it - back go
> [search engine].
> 
> In that case, even if the site's page rank doesn't decrease, the
> search results are out-of-sync and thus inaccurate. The site can
> definitely take a hit with regard to end-user perception and can cause
> annoyed users to leave and/or ignore your site, which are more
> important issues than a number from some search engine's algorithm.
> After all, it doesn't matter how many people Google, Bing, Yahoo or
> some other search engine sends your way if those users end up
> frustrated by the experience and don't actually use the site once they
> get there.

Yeah, these are also my concerns with the approach and we've been
careful to point them out to our client. If they know the potential
risks and they still want to go ahead then we've just got to live with
it, even if we don't agree that it's the right solution. The customer is
always right after all!

Cheers for the comments :)

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Andrew Ballard
On Fri, Aug 20, 2010 at 9:31 AM, Colin Guthrie  wrote:
> 'Twas brillig, and Andrew Ballard at 20/08/10 14:24 did gyre and gimble:
>> Would it work to return a list of some limited number of randomly
>> ordered "featured" listings/items on the page, while leaving the full
>> list ordered by whatever natural ordering (by date, order entered,
>> alphabetical, etc.)? That gives every owner a chance to appear in a
>> prominent spot on the page while solving the issue you cited about
>> page breaks (and SEO if that is a concern). You can still use any of
>> the suggestions that have been discussed to determine how frequently
>> the featured items list is reseeded to help make caching practical.
>
> Yeah we've tried to push this as an option too, but so far our clients
> are not biting on this suggestion. They like the idea but in
> addition to randomised listings too!
>
> Speaking of SEO, that was one of our concerns about randomising listings
> too. What impact do you think such randomised listings will have on SEO?
>
> Obviously if a term is matched for a listing page that contains a thing
> and when the user visits that page, the thing itself is not on in the
> listing, then the user will be disappointed, but will this actually
> result in SEO penalties?
>
> Col

I'm not sure it would penalize you in the algorithms. I was thinking
more of the number of times I have followed a promising-looking link
and found that the site where I was directed was a page of and index
of article headings or post subjects showing results 1000-1500 out of
1+, and the item I was hoping to see is no longer on that page. Is
it on the next page? No. Next page? No. Oh, forget it - back go
[search engine].

In that case, even if the site's page rank doesn't decrease, the
search results are out-of-sync and thus inaccurate. The site can
definitely take a hit with regard to end-user perception and can cause
annoyed users to leave and/or ignore your site, which are more
important issues than a number from some search engine's algorithm.
After all, it doesn't matter how many people Google, Bing, Yahoo or
some other search engine sends your way if those users end up
frustrated by the experience and don't actually use the site once they
get there.

Andrew

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



[PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Colin Guthrie
'Twas brillig, and Andrew Ballard at 20/08/10 14:24 did gyre and gimble:
> Would it work to return a list of some limited number of randomly
> ordered "featured" listings/items on the page, while leaving the full
> list ordered by whatever natural ordering (by date, order entered,
> alphabetical, etc.)? That gives every owner a chance to appear in a
> prominent spot on the page while solving the issue you cited about
> page breaks (and SEO if that is a concern). You can still use any of
> the suggestions that have been discussed to determine how frequently
> the featured items list is reseeded to help make caching practical.

Yeah we've tried to push this as an option too, but so far our clients
are not biting on this suggestion. They like the idea but in
addition to randomised listings too!

Speaking of SEO, that was one of our concerns about randomising listings
too. What impact do you think such randomised listings will have on SEO?

Obviously if a term is matched for a listing page that contains a thing
and when the user visits that page, the thing itself is not on in the
listing, then the user will be disappointed, but will this actually
result in SEO penalties?

Col




-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-20 Thread Nisse Engström
On Fri, 20 Aug 2010 13:11:05 +0100, Nathan Rixham wrote:

> Nisse Engström wrote:
> 
>> Actually, the HTTP spec. allows most headers to be sent
>> after the content. The feature just wasn't implemented
>> by too many HTTP agents (W3's HTML validator and link
>> checker, and Opera).
> 
> can you send a link to where it says that in the spec, or in HTTPBis please





/Nisse

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



Re: [PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Andrew Ballard
On Fri, Aug 20, 2010 at 9:05 AM, Colin Guthrie  wrote:
> Thanks everyone for responses.
>
> 'Twas brillig, and Nathan Rixham at 20/08/10 13:17 did gyre and gimble:
>> if you use mysql you can seed rand() with a number to get the same
>> random results out each time (for that seed number)
>>
>>   SELECT * from table ORDER BY RAND(234)
>>
>> Then just use limit and offset as normal.
>
> This is a neat trick! Yeah that will avoid the need for the static
> lookup table with 32 randomised columns.

Would it work to return a list of some limited number of randomly
ordered "featured" listings/items on the page, while leaving the full
list ordered by whatever natural ordering (by date, order entered,
alphabetical, etc.)? That gives every owner a chance to appear in a
prominent spot on the page while solving the issue you cited about
page breaks (and SEO if that is a concern). You can still use any of
the suggestions that have been discussed to determine how frequently
the featured items list is reseeded to help make caching practical.

Just a thought.

Andrew

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



[PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Colin Guthrie
Thanks everyone for responses.

'Twas brillig, and Nathan Rixham at 20/08/10 13:17 did gyre and gimble:
> if you use mysql you can seed rand() with a number to get the same
> random results out each time (for that seed number)
> 
>   SELECT * from table ORDER BY RAND(234)
> 
> Then just use limit and offset as normal.

This is a neat trick! Yeah that will avoid the need for the static
lookup table with 32 randomised columns.

Jon's strategy is more or less a simplified version of my 32-column
randomising table (i.e. just have 1 column of random data rather than
32). I would personally prefer to reduce the refresh of this data as I
don't like to annoy people when the change over day happens.

The RAND(seed) approach will probably work well (not sure of performance
verses an indexed table, but I can easily experiment with this).

If I use the numbers 1..32 as my seed, then I still get the same net
result as a 32 column table. If I just change my "seed offset" then I
get the same result as re-generating my random data tables.

>From an operational perspective, RAND(seed) is certainly easier.

I'll certainly look into this. Many thanks.

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread tedd

At 10:00 AM +0100 8/20/10, Colin Guthrie wrote:

Are there any other approaches I've missed? Is there some cunning,
cleverness that eludes me?

Col


Col:

I don't know about being clever, but the problem reminds me of 
selling ad space on web sites.


I read a book about it, namely "OpenX Ad Server" by Yilmaz

It provided a lot of back-end considerations for displaying ads, such as:

1. How to randomly preference some ads over others. To give 
preference to gold over silver by simply having more gold ads than 
silver ads in the collection of ads to pick a random selection. For 
example, if you have twenty gold ads and ten silver and randomly 
pick, then gold has a a 2:1 advantage even though the pick is random.


2. What time of day show ads per location of user -- you see, each 
time zone has it's own "busy" time and ads shown during those times 
are at an advantage. For example your web site may be showing one set 
of ads for CA, another for MO, and another for MI all at the same 
local time.


3. And other such considerations -- it might be worth the cost to 
purchase and review. They did a pretty in-depth study of how to track 
and optimize ad sales.


Cheers,

tedd

--
---
http://sperling.com/

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



[PHP] Re: Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Nathan Rixham

Colin Guthrie wrote:

Hi,

OK, this is really just a sounding board for a couple ideas I'm mulling
over regarding a pseudo-randomisation system for some websites I'm
doing. Any thoughts on the subject greatly appreciated!

Back Story:

We have a system that lists things. The things are broken down by
category, but you can still end up at the leaf of the category with a
couple hundred things to list, which is done via a pagination system
(lets say 50 per page).


Now, the people who own the things pay to have their things on the site.
Lets say there are three levels of option for listing: gold, silver,
bronze. The default order is gold things, silver things then bronze
things. Within each level, the things are listed alphabetically (again
this is just the default).


Now if 100 things in one category have a gold level listing, those in
the second half of the alphabet will be on page two by default. They
don't like this and they question why they are paying for gold at all.

My client would like to present things in a more random way to give all
gold level things a chance to be on the first page of results in a
fairer way than just what they happen to be named.

Right that's the back story. It's more complex than that, but the above
is a nice and simple abstraction.


Problems:

There are numerous problems to randomised listings: you can't actually
truly randomise results otherwise pagination breaks. Server-side
caching/denationalisation is affected as there is no longer "one
listing" but "many random listings". Discussing a link with a friend
over IM or email and saying things like "the third one down looks best"
is obviously broken too, but this is something my client accepts and can
live with. Also, if the intention is to reassure the thing owners that
their listing will appear further up the listings at times, the fact
that a simple refresh will not reorder things for a given session will
make that point harder to get across to less web-educated clients
(that's a nice way of saying it!). Caching proxies and other similar
things after the webserver will also come into play.


So to me there are only really two options:

1. Random-per user (or session): Each user session gets some kind of
randomisation key and a fresh set of random numbers is generated for
each thing. They can then be reliably "randomised" for a given user. The
fact that each user has their own unique randomisation is good, but it
doesn't help things like server side full page caching and thus more
"work" needs to be done to support this approach.

2. Random-bank + user/session assignment: So with this approach we have
a simple table of numbers. First column is an id and is sequential form
1 to . This table has lots of columns: say 32. These
columns will store a random number. Once generated, this table acts as
an orderer. It can be joined into our thing lookup query and the results
can be ordered by one of the columns. Which column to use for ordering
is picked by a cookie stored on the users machine. That way the user
will always get the same random result, even if they revisit the site
some time later (users not accepting cookies is not a huge deal, but I
would suggest the "pick a random column" algorithm (used to set the
cookie initially) is actually based on source IP address. That way even
cookieless folks should get a consistent listing unless their change
their IP).



I'm obviously leaning towards the second approach. If I have 32
"pre-randomised" columns, this would get a pretty good end result I
think. If we re-randomise periodically (i.e. once a week or month) then
this can be extended further (or simply more columns can be added).

I think it's the lowest impact but there are sill some concerns:

Server side caching is still problematic. Instead of storing one page
per "result" I now have to store 32. This will lower significantly the
cache hits and perhaps make full result caching somewhat redundant. If
that is the case, then so be it, but load will have to be managed.


So my question for the lazy-web:

Are there any other approaches I've missed? Is there some cunning,
cleverness that eludes me?

Are there any problems with the above approach? Would a caching proxy
ultimately cause problems for some users (i.e. storing a cache for page
1 and page 2 of the same listing but with different randomisations)? And
if so can this be mitigated?

Thanks for reading and any insights you may have!


if you use mysql you can seed rand() with a number to get the same 
random results out each time (for that seed number)


  SELECT * from table ORDER BY RAND(234)

Then just use limit and offset as normal.

Thus, assign each user / session a simple random int, and use it in the 
query.


on a semi related note, if you need real random data, then you'll be 
wanting random.org


Best,

Nathan



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



[PHP] mod_php

2010-08-20 Thread Stanisław Findeisen
Hi

Could anyone please explain to me the basic architecture of PHP module
when running "in process" within Apache HTTP server?
I guess this is called "mod_php".

As far as I understand the shared library (e.g., libphp5.so) is being
dynamically loaded by an Apache working process and then, whenever a
.php (or .php3, or...) file is requested the working process calls the
PHP interpreter. This call to the PHP interpreter is a function call and
there is no fork(2) nor execve(2) in play at all.

Is this correct?

STF

http://eisenbits.homelinux.net/~stf/
OpenPGP: DFD9 0146 3794 9CF6 17EA  D63F DBF5 8AA8 3B31 FE8A

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



[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-20 Thread Nathan Rixham

Nisse Engström wrote:

On Thu, 19 Aug 2010 17:47:01 -0600, Tristan wrote:


A rewrite of the entire site would be needed in order to fix. So, I guess
you are saying as best options for workaround are

- use the ob_ functions to work around.
- stick output buffer on or high

so best case scenario using ob_ functions as a cleaner method aside from
rewriting the code?

seems silly btw that you can't output html and just have it redirect
whenever you want it to at any point in the page.


Actually, the HTTP spec. allows most headers to be sent
after the content. The feature just wasn't implemented
by too many HTTP agents (W3's HTML validator and link
checker, and Opera).


can you send a link to where it says that in the spec, or in HTTPBis please

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



RE: [PHP] Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Jon Haworth
Hi Col,

Interesting problem.

> Are there any other approaches I've missed? 

Off the top of my head, how about this:

1. Add a new unsigned int column called "SortOrder" to the table of widgets
or whatever it is you're listing

2. Fill this column with randomly-generated numbers between 0 and whatever
the unsigned int max is (can't remember exactly but 4.2 billion ish)

3. Add the SortOrder column to the end of all your ORDER BY clauses - SELECT
foo ORDER BY TypeOfListing, SortOrder will give you widgets sorted by
Gold/Silver/Bronze type, but in a random order for each type

4. Every hour/day/week/whatever, update this column with different random
numbers

Advantages: practically no hassle/overhead/maintenance for you; provides
same ordering sequence for all users at the same time; only breaks "third
one down"-type references when you refresh the SortOrder column rather than
on each session or page view; reasonably proxy- and cache-friendly
especially if you send a meaningful HTTP Expires header.

Disadvantages: breaks user persistence if they visit before and after a
SortOrder refresh ("I'm sure the one I wanted was at the top of the list
yesterday..."); more effort to demonstrate randomness to the client ("OK,
see how you're in ninety-third place today? Well, check again tomorrow and
you should be somewhere else on the list").

Hopefully food for thought anyway.

Cheers
Jon


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



Re: [PHP] tutorial failure

2010-08-20 Thread Ashley Sheridan
On Fri, 2010-08-20 at 10:00 +0100, e-letter wrote:

> On 19/08/2010, Ashley Sheridan  wrote:
> > No, because Apache doesn't need to process HTML in the same way it needs
> > to process PHP. The tag  > browser as HTML (view the source on the page you're browsing to) and
> > interpreted as a tag by your browser, hence what appears to be partially
> > processed output.
> >
> > It's fairly clear by now that Apache does not know about your PHP
> > install (if there even is one)
> >
> > I've just set up and installed PHP and Apache on my Mandriva box since
> > I've been at home, and it took all of 5 minutes from within the package
> > manager. Trust me, it's far easier to go that route than install the
> > packages one-by-one as you seem to be doing as, unless you know exactly
> > what packages you need, it's all too easy to miss installing something.
> >
> Yes that is what I was inspecting; I plan to re-install the entire OS.
> 


You don't have to reinstall the entire OS, that's a very Windows
approach to the problem. I played around a bit last night with urpmi and
you should be able to just list the packages you need with urpmq --fuzzy
package_name, and then install the ones listed you think you need. I did
notice that urpmi doesn't install the DB when you install the Apache mod
for that DB, so you might need to install that separately, but other
than that, you should be good to go if you install the Apache php mod.


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




[PHP] Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites

2010-08-20 Thread Colin Guthrie
Hi,

OK, this is really just a sounding board for a couple ideas I'm mulling
over regarding a pseudo-randomisation system for some websites I'm
doing. Any thoughts on the subject greatly appreciated!

Back Story:

We have a system that lists things. The things are broken down by
category, but you can still end up at the leaf of the category with a
couple hundred things to list, which is done via a pagination system
(lets say 50 per page).


Now, the people who own the things pay to have their things on the site.
Lets say there are three levels of option for listing: gold, silver,
bronze. The default order is gold things, silver things then bronze
things. Within each level, the things are listed alphabetically (again
this is just the default).


Now if 100 things in one category have a gold level listing, those in
the second half of the alphabet will be on page two by default. They
don't like this and they question why they are paying for gold at all.

My client would like to present things in a more random way to give all
gold level things a chance to be on the first page of results in a
fairer way than just what they happen to be named.

Right that's the back story. It's more complex than that, but the above
is a nice and simple abstraction.


Problems:

There are numerous problems to randomised listings: you can't actually
truly randomise results otherwise pagination breaks. Server-side
caching/denationalisation is affected as there is no longer "one
listing" but "many random listings". Discussing a link with a friend
over IM or email and saying things like "the third one down looks best"
is obviously broken too, but this is something my client accepts and can
live with. Also, if the intention is to reassure the thing owners that
their listing will appear further up the listings at times, the fact
that a simple refresh will not reorder things for a given session will
make that point harder to get across to less web-educated clients
(that's a nice way of saying it!). Caching proxies and other similar
things after the webserver will also come into play.


So to me there are only really two options:

1. Random-per user (or session): Each user session gets some kind of
randomisation key and a fresh set of random numbers is generated for
each thing. They can then be reliably "randomised" for a given user. The
fact that each user has their own unique randomisation is good, but it
doesn't help things like server side full page caching and thus more
"work" needs to be done to support this approach.

2. Random-bank + user/session assignment: So with this approach we have
a simple table of numbers. First column is an id and is sequential form
1 to . This table has lots of columns: say 32. These
columns will store a random number. Once generated, this table acts as
an orderer. It can be joined into our thing lookup query and the results
can be ordered by one of the columns. Which column to use for ordering
is picked by a cookie stored on the users machine. That way the user
will always get the same random result, even if they revisit the site
some time later (users not accepting cookies is not a huge deal, but I
would suggest the "pick a random column" algorithm (used to set the
cookie initially) is actually based on source IP address. That way even
cookieless folks should get a consistent listing unless their change
their IP).



I'm obviously leaning towards the second approach. If I have 32
"pre-randomised" columns, this would get a pretty good end result I
think. If we re-randomise periodically (i.e. once a week or month) then
this can be extended further (or simply more columns can be added).

I think it's the lowest impact but there are sill some concerns:

Server side caching is still problematic. Instead of storing one page
per "result" I now have to store 32. This will lower significantly the
cache hits and perhaps make full result caching somewhat redundant. If
that is the case, then so be it, but load will have to be managed.


So my question for the lazy-web:

Are there any other approaches I've missed? Is there some cunning,
cleverness that eludes me?

Are there any problems with the above approach? Would a caching proxy
ultimately cause problems for some users (i.e. storing a cache for page
1 and page 2 of the same listing but with different randomisations)? And
if so can this be mitigated?

Thanks for reading and any insights you may have!


Col






-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] tutorial failure

2010-08-20 Thread e-letter
On 19/08/2010, Ashley Sheridan  wrote:
> No, because Apache doesn't need to process HTML in the same way it needs
> to process PHP. The tag  browser as HTML (view the source on the page you're browsing to) and
> interpreted as a tag by your browser, hence what appears to be partially
> processed output.
>
> It's fairly clear by now that Apache does not know about your PHP
> install (if there even is one)
>
> I've just set up and installed PHP and Apache on my Mandriva box since
> I've been at home, and it took all of 5 minutes from within the package
> manager. Trust me, it's far easier to go that route than install the
> packages one-by-one as you seem to be doing as, unless you know exactly
> what packages you need, it's all too easy to miss installing something.
>
Yes that is what I was inspecting; I plan to re-install the entire OS.

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



[PHP] Re: tutorial failure

2010-08-20 Thread Colin Guthrie
'Twas brillig, and Ashley Sheridan at 19/08/10 23:16 did gyre and gimble:
> I used the GUI: K-Menu->Configure your Computer->Install & Remove
> Software
> 
> Then searched for 'php', and the first package listed was
> apache-mod_php, which I installed along with the other php modules that
> I normally install (like GD, mcrypt, etc). The package manager sorts out
> dependencies very well. I'm not sure if installing over the command line
> with rpmi will deal with dependencies like this, and it certainly won't
> automatically install apache-mod_php if php is installed, as php doesn't
> necessarily *have* to run as a web server module, let alone as an Apache
> one specifically.

Just for reference:

1. The Package Manager GUI will indeed sort it all out for you.

2. The Package Manager GUI is just a frontend for urpmi. All the
dependency tracking etc. is in urpmi. It's very much like Yum, but IMO
is easer to use and better at reporting conflicts and other such things.
But to each his own :)

3. Just install task-lamp. Who cares that you get mysql installed? I
doubt the space overhead is a problem and I'm very much presuming that
this is your development PC. No offence intended (we were all new once)
the fact that you are asking the questions you are means that this
simply *cannot* be a production setup!

If you have any doubt and want to be more specific, just install
task-lamp-php. All of these are listed in the Package Manager GUI. Just
pick "Meta Packages" and then look under System->Servers (or just search
for the name: staring the GUI and typing "lamp" into the search box is
really all that's needed).

4. Yes PHP can be installed as cgi, apache module or command line. There
is no such thing as "installing php" - you install which system you
want: command line (php-cli), apache module (apache-mod_php) or cgi
(php-cgi). I work with LAMP stacks on various flavours servers and I
find the Mandriva one to be very, very well thought out, and very
flexibly mainly due to the excellent work of Oden Ericsson.

Col




-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



[PHP] Re: [OUTPUT BUFFER] - problems with redirects

2010-08-20 Thread Nisse Engström
On Thu, 19 Aug 2010 17:47:01 -0600, Tristan wrote:

> A rewrite of the entire site would be needed in order to fix. So, I guess
> you are saying as best options for workaround are
> 
> - use the ob_ functions to work around.
> - stick output buffer on or high
> 
> so best case scenario using ob_ functions as a cleaner method aside from
> rewriting the code?
> 
> seems silly btw that you can't output html and just have it redirect
> whenever you want it to at any point in the page.

Actually, the HTTP spec. allows most headers to be sent
after the content. The feature just wasn't implemented
by too many HTTP agents (W3's HTML validator and link
checker, and Opera).


/Nisse

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