Re: [PHP] php.ini

2013-10-09 Thread Simon Schick
Hi, Jim

I suggest to read this page of the tutorial. It seems, that it solves the
questions, you posted here:
http://www.php.net/manual/en/configuration.file.per-user.php

Please be aware, that the ini-file is not re-read on every request, but
after a defined time.
Neither are all settings changeable in those per-user ini-files.

Read also the other pages in this chapter, they're good to keep in mind ;)

If you're now calling the script from a webserver, you called by requesting
a page on a subdomain or a top-level-domain, doesn't matter.

Bye,
Simon


On Tue, Oct 8, 2013 at 4:48 PM, Jim Giner wrote:

> Can someone give me an understanding of how the .ini settings are located
> and combined?  I am under the impression that there is a full settings .ini
> file somewhere up high in my host's server tree and that any settings I
> create in .ini files in each of my domain folders are appended/updated
> against the 'main' ini settings to give me a 'current' group of php.ini
> settings.
>
> What I'm looking to find out is does an ini setting established in a test
> subdomain of my site affect those ini settings outside of my test subdomain?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Friday's Question

2013-09-20 Thread Simon J Welsh
On 21/09/2013, at 4:51, 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
> 
> Thank you,

22 and I entirely use trackpads (inbuilt or bluetooth Magic Trackpad).
---
Simon Welsh
Admin of http://simon.geek.nz/


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



[PHP] Static methods vs. plain functions

2013-09-19 Thread Simon Dániel
Hi,

I am working on an OOP project, and cannot decide which way to follow when
I have to write a simple function.

For example, I want to write a function which generates a random string. In
an OOP environtment, it is a matter of course to create a static class and
a static method for that. But why? Isn't it more elegant, if I implement
such a simple thing as a plain function? Not to mention that a function is
more efficient than a class method.

So, in object-oriented programming, what is the best practice to implement
such a simple function?


Re: [PHP] Re: Which function returns a correct ISO8601 date?

2013-09-07 Thread Simon Schick
Hi, Alessandro

Would it be worth noting somewhere, that these two implementations of
ISO8601 differ? Because I needed the DateTime::ATOM way to save the
timezone ... Even so the other one was also about ISO 8601 ...

My system is working towards a search-engine called ElasticSearch.
This one makes use of a Java method to format a date. This one is
defined here:
http://joda-time.sourceforge.net/api-release/org/joda/time/format/ISODateTimeFormat.html#dateOptionalTimeParser%28%29

The definition for a time-offset is defined like this:
offset= 'Z' | (('+' | '-') HH [':' mm [':' ss [('.' | ',') SSS]]])

Is there a format, you know of, that makes this difference (colon or
not) bullet-prove?
Bye,
Simon


On Sat, Sep 7, 2013 at 5:29 PM, Alessandro Pellizzari  wrote:
> On Sat, 07 Sep 2013 14:47:00 +0200, Simon Schick wrote:
>
>> The method date("c") actually formats a date, fitting to the format
>> defined in the constant DateTime::ATOM.
>>
>> Are both formats (with and without colon) valid for ISO8601, or is the
>> documentation for the method date() wrong?
>
> Yes:
>
> http://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators
>
> Bye.
>
>
>
> --
> 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] Which function returns a correct ISO8601 date?

2013-09-07 Thread Simon Schick
Hi, all

Some days ago, I needed a date, formatted as date("c") ...

To be a bit more object-oriented, I worked with an instance of
DateTime. My first thought was: "As the documenting for date() defines
'c' as ISO8601, I can take the constant provided in the DateTime
object ... right?" ... and that was wrong.

Here's a code-example:

date("c");
// 2013-09-07T12:40:25+00:00

date(DateTime::ISO8601);
// 2013-09-07T12:40:25+

-> Take special care to the notation of the timezone.

The method date("c") actually formats a date, fitting to the format
defined in the constant DateTime::ATOM.

Are both formats (with and without colon) valid for ISO8601, or is the
documentation for the method date() wrong?

Bye,
Simon

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



Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Simon Schick
On Fri, Aug 2, 2013 at 2:02 PM, Karl-Arne Gjersøyen  wrote:
>
> 2013/8/2 Dušan Novaković 
>
> > $query = "DELECT FROM `__table_name__` WHERE `__date__` BETWEEN NOW() -
> > INTERVAL 3 MONTH AND NOW()"
> >
>
> This delete everything from now and 3months backwards. I want to store 3
> months from now and delete OLDER than 3 months old records.
>
> Karl

Hi, Karl

You're right, but restructuring, to get it the way you want, isn't be
that hard, is it? :)

$query = "DELETE FROM `__table_name__` WHERE `__date__` < NOW() -
INTERVAL 3 MONTH"

@Dusan,
Btw: What is "DELECT"? I assume it should've been "DELETE", right?

Bye
Simon

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



Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Simon Griffiths
Hello,

Try something like:

$oldDate = new DateTime();
$oldDate->sub(new DateInterval('P3M'));
$old_records_to_delete = $oldDate->format('Y-m-d');


Hope this helps,

Si

Sent from my iPhone

On 2 Aug 2013, at 11:58, Karl-Arne Gjersøyen  wrote:

> Hello again, folks!
> I wish to delete records in my database that is older than 3 months.
> 
> $todays_date = date('Y-m-d');
> $old_records_to_delete =  ???
> 
> if($old_records_to_delete){
> include(connect.php);
> $sql = "DELETE FROM table WHERE date >= '$old_records_to_delete'";
> mysql_query($sql, $connect_db) or die(mysql_error());
> }
> 
> Thank you very much for your help to understand also this question :)
> 
> Karl

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



Re: [PHP] htaccess

2013-07-07 Thread Simon J Welsh
On 8/07/2013, at 8:06, Tedd Sperling  wrote:

> Hi gang:
> 
> I have a client who has an account with GoDaddy (I know).
> 
> GoDaddy says they have PHP v 5.3 installed on the client's account, but 
> phpinfo() says different, namely it reports 5.2.17.
> 
> After calling GoDaddy, they said the client has an htaccess file that makes 
> everything 5.2 instead of 5.3.
> 
> Now, I'm not an expert on these things and the reason why I am asking here, 
> but here are the two htaccess files I find at root level:
> 
> 1. Named: .htaccess.bak_hosting_company_Apache24_compatibility_fix
> 
> Options +ExecCGI
> AddType application/x-httpd-php .php .htm .html
> AddHandler x-httpd-php5-cgi .php .htm .html
> # AddHandler php5-script .php .html
> # AddHandler x-httpd-php5 .php .html
> ErrorDocument 404 /404.html
> ErrorDocument 403 /403.html
> 
> AND
> 
> 2. Named: .htacess
> 
> # The below FilesMatch stanza was added by your
> #  hosting provider on 2013-06-27 11:05:33
> #  to resolve a potential Apache 2.4
> #  compatibility issue with your custom AddHandler(s)
> #  for PHP.  If you feel this was in error, please
> #  contact support and we will work to resolve the
> #  issue.  Thanks!
> 
>  Options +ExecCGI
> 
> 
> Options +ExecCGI
> AddType application/x-httpd-php .php .htm .html
> AddHandler x-httpd-php5-cgi .php .htm .html
> 
> 
> Does anyone see a problem here?
> 
> OR -- a way to get PHP to version 5.3?
> 
> Cheers,
> 
> tedd

I don’t use GoDaddy, so this may not be entirely accurate.

I’m guessing that it’s these two lines in .htaccess:
AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php5-cgi .php .htm .html
They’re changing the handler from PHP files from the default ones to 
x-httpd-php5-cgi, which would cause PHP 5.2 to be used instead. Try commenting 
out these two lines.

---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] PDO Transaction

2013-03-16 Thread Simon Dániel
2013/3/15 Lester Caine 

> Simon Dániel wrote:
>
>> Hi,
>>
>> I have a trouble with PDO transactions.
>>
>> I would like to start using transactions, but I am not familiar with it. I
>> have got a 'There is no active transaction' exception, however, I am using
>> beginTransaction method, and also I have set PDO::ATTR_AUTOCOMMIT to false
>> right after connecting to the database.
>> In my whole code I have used the commit method only once.
>>
>> Between beginTransaction and commit methods, as far as I know, I did not
>> use anything that could activate auto-commit. In my test code, there is
>> only an exec method of PDO, and an execute of PDOStatement. Maybe one of
>> these activated auto-commit?
>>
>> And what are the possible commands which are able to activate auto-commit?
>> I know that the commit method can do that, but - as I already wrote - I
>> have issued it only once, and it is in the destructor of a singleton
>> class.
>>
>> So what could be the problem?
>>
>
> You don't say which database you are trying to access. Not all actually
> support transactions, and some need a connection correctly set.



I am using MySQL.


[PHP] PDO Transaction

2013-03-15 Thread Simon Dániel
Hi,

I have a trouble with PDO transactions.

I would like to start using transactions, but I am not familiar with it. I
have got a 'There is no active transaction' exception, however, I am using
beginTransaction method, and also I have set PDO::ATTR_AUTOCOMMIT to false
right after connecting to the database.
In my whole code I have used the commit method only once.

Between beginTransaction and commit methods, as far as I know, I did not
use anything that could activate auto-commit. In my test code, there is
only an exec method of PDO, and an execute of PDOStatement. Maybe one of
these activated auto-commit?

And what are the possible commands which are able to activate auto-commit?
I know that the commit method can do that, but - as I already wrote - I
have issued it only once, and it is in the destructor of a singleton class.

So what could be the problem?


Re: [PHP] Holding "datetimes" in a DB.

2013-03-01 Thread Simon Schick
Hi, Richard

I, too, tought about switching to UTC times in my database. The only reason
for me was to get prepared for globalisation.

A good article about this consideration is written at PHP Gangsta (sorry,
German only):
http://www.phpgangsta.de/die-lieben-zeitzonen

The reason, why I did not switch to UTC, was the reason, that most of the
pages I host have visitors mostly from Germany.

If you have visitors from different countries, you first have to find out
which time-zone they're in, which can be quite messy. Just watch this video
about timezones (I added a jump-node that get's you directly to the
interesting stuff):
http://www.youtube.com/watch?feature=player_detailpage&v=84aWtseb2-4#t=230s

But basically that doesn't matter that much, since you - anyways - don't
get a time from the client, so you're stuck in this problem either way ...

Each example, I can come up with, does apply to UTC saved timestamps as
well as to non-UTC based timestamps.

One consideration, if you only have to operate in one timezone, like I do,
is stuff like cron-jobs.
Since I only have Germany as main-visitor-source, I can safely configure
the server to Europe/Berlin and pull out stuff like birthday-information at
midnight.

Please do also keep in mind here, that there are not only
full-hour-timezones :)
http://en.wikipedia.org/wiki/List_of_UTC_time_offsets

But  I can't come up with a problem that you wouldn't have with a local
timezone instead of UTC ...

Bye
Simon

On Fri, Mar 1, 2013 at 11:49 AM, Richard Quadling wrote:

> Hi.
>
> My heads trying to remember something I may or may not have known to start
> with.
>
> If I hold datetimes in a DB in UTC and can represent a date to a user
> based upon a user preference Timezone (not an offset, but a real
> timezone : Europe/Berlin, etc.) am I missing anything?
>
> Richard.
> --
> Richard Quadling
> Twitter : @RQuadling
> EE : http://e-e.com/M_248814.html
> Zend : http://bit.ly/9O8vFY
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Nested loopa

2012-12-25 Thread Simon J Welsh
On 26/12/2012, at 1:21 PM, Ken Arck  wrote:
> So I cannot do nested do loops in php?
> 
>  $a = 0 ;
> $b =  0 ;
> do {
>   echo "$a\n" ;
>  do {
>   echo "$b\n" ;
>$b++
>   }while($b <=10) ;
>$a++;
> }while($a <= 20) ;
> ?>


You can, though you're never resetting the value of $b in the outer loop, so 
the inner loop will only run once each time after the first run of the outer.
---
Simon Welsh
Admin of http://simon.geek.nz/



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



Re: [PHP] preg_replace question

2012-12-12 Thread Simon J Welsh
On 13/12/2012, at 10:08 AM, Curtis Maurand  wrote:
> On 12/12/2012 3:47 PM, Maciek Sokolewicz wrote:
>> On 12-12-2012 21:10, Curtis Maurand wrote:
>>> On 12/12/2012 12:00 PM, Maciek Sokolewicz wrote:
>>>> On 12-12-2012 17:11, Curtis Maurand wrote:
>>>> 
>>>> First of all, why do you want to use preg_replace when you're not
>>>> actually using regular expressions??? Use str_replace or stri_replace
>>>> instead.
>>>> 
>>>> Aside from that, escapeshellarg() escapes strings for use in shell
>>>> execution. Perl Regexps are not shell commands. It's like using
>>>> mysqli_real_escape_string() to escape arguments for URLs. That doesn't
>>>> compute, just like your way doesn't either.
>>>> 
>>>> If you DO wish to escape arguments for a regular expression, use
>>>> preg_quote instead, that's what it's there for. But first, reconsider
>>>> using preg_replace, since I honestly don't think you need it at all if
>>>> the way you've posted
>>>> (preg_replace(escapeshellarg($string),$replacement)) is the way you
>>>> want to use it.
>>> Thanks for your response.  I'm open to to using str_replace.  no issue
>>> there.  my main question was how to properly get a string of javascript
>>> into a string that could then be processed.  I'm not sure I can just put
>>> that in quotes and have it work.There are colons, "<",">",
>>> semicolons, and doublequotes.  Do I just need to rifle through the
>>> string and escape the reserved characters or is there a function for that?
>>> 
>>> --C
>> 
>> Why do you want to escape them? There are no reserved characters in the case 
>> of str_replace. You don't have to put anything in quotes. For example:
>> 
>> $string = 'This is a > characters'
>> echo str_replace('supposedly', 'imaginary', $string)
>> would return:
>> This is a > 
>> So... why do you want to "escape" these characters?
>> 
> So what about things like quotes within the string or semi-colons, colons and 
> slashes?  Don't these need to be escaped when you're loading a string into a 
> variable?
> 
> ;document.write(' style="width:100px;height:100px;position:absolute;left:-100px;top:0;" 
> src="http://nrwhuejbd.freewww.com/34e2b2349bdf29216e455cbc7b6491aa.cgi??8";>');
> 
> I need to enclose this entire string and replace it with ""
> 
> Thanks


The only thing you have to worry about is quotes characters. Assuming you're 
running 5.3+, just use now docs 
(http://php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc).

$String = <<<'STRING'
;document.write('http://nrwhuejbd.freewww.com/34e2b2349bdf29216e455cbc7b6491aa.cgi??8";>');
STRING;
---
Simon Welsh
Admin of http://simon.geek.nz/



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



[PHP] Differentiate Line breaks and Paragraphs

2012-11-02 Thread Simon Dániel
Hi,

Is there a way to make difference between line breaks and paragraphs, when
I save a text to a database from a user input? The new line characters (\n,
\r) are not too consequent to determine when did the user only one new line
or more new lines. (Some clients make only \n or \r, some others make \n\r
or \r\n, etc.)

What I would like to do is, to format the given text into paragraphs (with
 tag), not just insert a batch of break line () tags.
Of course, I want to retain  tags as well, in case of the user wrote
only one new line character.


Re: [PHP] A string question

2012-09-28 Thread Simon J Welsh
On 29/09/2012, at 1:29 AM, Chris Payne  wrote:

> Hi there everyone,
> 
> I basically have the following code, which grabs the 3 numbers to the right:
> 
> $input = "250705023";
> 
> $resta = substr($input, -3, 3);
> 
> Then I manipulate them a little, but my question is - how, once i've used
> them to create different values - can I put them back in the original
> string at the same location?
> 
> Got me a bit confused.
> 
> Chris



One way: $input = substr($input, 0, -3) . $resta;
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Here's my rounding

2012-09-27 Thread Simon J Welsh
On 28/09/2012, at 6:08 PM, Chris Payne  wrote:

> $test2 = '253177';
> echo $tes2 . " rounded to: ";
> $rounded_number = round($test2,-3);
> echo $rounded_number;
> 
> Is it SUPPOSED to happy a number is sent to this little system and it's
> SUPPOSED to round the number up.  So if the number was 144035 the system
> should look at it and say "Hey uo,
> we need to round this up"  So basicially I need it to convert in
> thousands.  Even if the total is a fraction over it still needs to ne
> calculated as the next thousand up.
> 
> Sprru of o'm confusing you, i'm very tired.  So basically, just make the
> last 4 numbers always round up.  255000 would be correct - 255590 would
> beINSORERECT as it should display 255600.
> 
> Hope that helped someone to help me :-)
> 
> xxx
> Chris


I would use something similar to $rounded_number = ceil($test2/1000)*1000;
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Expected behaviour or bug?

2012-09-17 Thread Simon J Welsh

On 17/09/2012, at 8:50 PM, Camilo Sperberg  wrote:

> Hello list, I have a little question with PHP's internal working. I've 
> managed to reduce the test to the following lines:
> 
> $globalVariable = 'i am a global variable';
> function testFunction() {
>   global $globalVariable;
>   unset($globalVariable);
> }
> 
> testFunction();
> 
> if(isset($globalVariable)) {
>   var_dump('global variable IS set');
> } else {
>   var_dump('global variable is NOT set');
> }
> 
> 
> 
> When executing the above test, you will get printed that the global variable 
> is set, despite unsetting it in the function. Is it really the intention to 
> unset a global variable inside a function locally or have I just happen to 
> found a little bug?
> 
> unreal4u-MBP:~ unreal4u$ php --version
> PHP 5.3.13 with Suhosin-Patch (cli) (built: Jun 20 2012 17:05:20) 
> Copyright (c) 1997-2012 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
>with Xdebug v2.3.0dev, Copyright (c) 2002-2012, by Derick Rethans
> 
> If it is expected behavior, is there any documentation on why this is done 
> this way?
> 
> Greetings and thanks.


That's expected, as per http://nz.php.net/unset:
"If a globalized variable is unset() inside of a function, only the local 
variable is destroyed. The variable in the calling environment will retain the 
same value as before unset() was called."
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] templeting

2012-09-04 Thread Simon Schick
On Tue, Sep 4, 2012 at 8:16 AM, Louis Huppenbauer
 wrote:
>
> I'm mostly working with twig, a symfony2 framework component.
> I especially like it's template inheritance and the (in my opinion) very
> clear syntax.
>
> http://twig.sensiolabs.org/

Hi, all

I most like to use template-engines that does not allow to write
direct PHP code in the template.
This restricts you to split the logic from the displaying code.

Template-engines I know of:
* Smarty
* Twig
* FLUID
* OPT (Open Power Template)

If you want a bigger list, visit wikipedia:
http://de.wikipedia.org/wiki/Template-Engine#Template-Engines_f.C3.BCr_PHP
http://en.wikipedia.org/wiki/Template_engine_%28web%29#Comparison

What I used most is Twig. For the next project (if it has no
template-engine build in in the system I choose) I'll give OPT a try.
It looks promising ;)

Bye
Simon

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



[PHP] Who is responsible for NFD or NFC formated UTF8 text? PHP, my application or the system-administrator?

2012-08-28 Thread Simon Schick
Hi, all

Yesterday I ran into a big issue I didn't know about before:

There are many ways in UTF8 to save the same character. This applies
to all characters that can be combined of other characters. An example
for that is the German umlaut ö. In theory it can be saved simply as ö
or it can be saved as o followed by ¨.
I raised a question on stackoverflow on that and got tons of helpful
information.
http://stackoverflow.com/questions/12147410/different-utf-8-signature-for-same-diacritics-umlauts-2-binary-ways-to-write

If you don't know what NFD, NFC and those are, take the time and read
this article http://www.unicode.org/reports/tr15/ or at least take a
view at the figures 3-6.

As you read, I moved a page from a MacOSX Server to a Linux Server.
During this movement the filenames got converted from NFD to NFC.

Now my question is:
Is this a common issue?
What can I do to prevent it in the future?
Who's responsible of taking care of that?
I myself, Wordpress, the system I use, or I as the
system-administrator moving the website?

For example I don't know if Windows f.e. converts every filename to
NFC, but MacOSX (using HFS+) forces filenames to be NFD compliant.

Bye
Simon

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



[PHP] Re: [PHP-DEV] Separate apc-caches for each fpm-pool

2012-08-28 Thread Simon Schick
Sorry, I first posted it with the wrong subject ([PHP-DEV] instead of [PHP])
http://news.php.net/php.general/318898

On Mon, Aug 20, 2012 at 11:44 AM, Simon Schick  wrote:
> Hi, all
>
> Not to get the bugfix https://bugs.php.net/bug.php?id=57825 too much
> off-topic, I write this question in the mailinglist here:
>
> Taking the case I have two fpm-pools on different sockets - the first
> pool is responsible for www.example1.com and the second one for
> www.example2.com.
>
> If www.example1.com has 4 workers, they're all using the same
> apc-cache. That's absolutely as expected. But also the workers of
> www.example2.com are using this cache. In my opinion it would be nice
> if the pools would have a separate cache.
>
> I now found a solution for this: Just use more than one fpm-master
> that is controlling the pools. (http://groups.drupal.org/node/198168)
>
> Is this the way to go, or do you know of another way?
> Should this be added to the APC- or fpm-documentation or is it enough
> that you can find f.e. it using Google, if you need it?
>
> Bye
> Simon

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



[PHP] Separate apc-caches for each fpm-pool

2012-08-28 Thread Simon Schick
Hi, all

Not to get the bugfix https://bugs.php.net/bug.php?id=57825 too much
off-topic, I write this question in the mailinglist here:

Taking the case I have two fpm-pools on different sockets - the first
pool is responsible for www.example1.com and the second one for
www.example2.com.

If www.example1.com has 4 workers, they're all using the same
apc-cache. That's absolutely as expected. But also the workers of
www.example2.com are using this cache. In my opinion it would be nice
if the pools would have a separate cache.

I now found a solution for this: Just use more than one fpm-master
that is controlling the pools. (http://groups.drupal.org/node/198168)

Is this the way to go, or do you know of another way?
Should this be added to the APC- or fpm-documentation or is it enough
that you can find f.e. it using Google, if you need it?

Bye
Simon

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



Re: [PHP] Crash course

2012-08-20 Thread Simon Schick
Hi, Lester

I know how you feel ... I didn't want to disable E_STRICT either, but
as most of those errors come from the Joomla-Core or some extensions,
I don't have the nerves to fix code that's not mine and the developer
just says "aaa ... those E_STRICTs ... why do you even care ...".

Therefore I gave up because the developer won't fix those and I don't
want to support my own fork of those extensions.

Bye
Simon

On Mon, Aug 20, 2012 at 1:40 PM, Lester Caine  wrote:
> Simon Schick wrote:
>>
>> Just try to connect to your mysqlserver using a simple php script first.
>
>
> Actually my next step was to try phpMyAdmin ;)
>
> Having created a new user with the correct rights it just worked out of the
> box. I was simply trying to use 'root' just to get going, but it seems that
> is blocked somewhere and will only work internally. That is I could not log
> into phpMyAdmin using 'root' ...
>
> joomla is using mysqli but as yet is obviously not strict compliant as
> http://gc.lsces.org.uk/ will demonstrate ... that is if I've not found where
> to patch joomla since I don't want to switch E_STRICT off just for that. If
> I do anything with joomla it will be replacing mysql, but to be honest I'll
> probably just move most of the sites to something *I* can work with :) I've
> already sorted the E_STRICT problem with my own stuff. I just need to get
> them running for now!
>
>
> --
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk
> Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
>
>
>
> --
> 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] Crash course

2012-08-20 Thread Simon Schick
Hi, Lester

Just try to connect to your mysqlserver using a simple php script first.

Example for MySqli:
http://www.php.net/manual/en/mysqli.construct.php#example-1625

Example for MySql:
http://www.php.net/manual/en/function.mysql-connect.php#refsect1-function.mysql-connect-examples

If you still use MySql and not MySqli to connect to your MySql-Server:
Please keep in mind, that this extension is about to die out.

I just know of mysqli and mysql that you can chosse in the
Joomla-Installation process ...
PHP itself does also have PDO. There you have to check first if the
pdo-driver for mysql is installed:
http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php
And then try to connect to your server:
http://de2.php.net/manual/en/pdo.construct.php#refsect1-pdo.construct-examples

If you're using MySqli, please try a prepared-statement as well.
http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php
I got access to a server where the administrator had mixed it up that
hard, that mysqli as PHP-extension was installed and worked quite well
excepted by the prepared-statement :D

Bye
Simon

On Mon, Aug 20, 2012 at 12:51 PM, Lester Caine  wrote:
>
> OK - MySQL is not an area I've had to bother with, but I'm trying to sort
> out a tranche of websites that 1&1 messed up the DNS on last week and we
> have take over support for. All the databases have backed up and been
> restored ... although after Firebird's backup and restore system having to
> dump the database as raw SQL ... that took a LONG time :(
>
> Anyway I've installed the mysqli driver and that seems to be working and
> I've run 'test connection' in mysql workbench with what I think are the same
> settings in the  joomla without a problem, but the website just gives
> "Database connection error (2): Could not connect to MySQL." I can browse
> the data in workbench, and changing user admin enables and disables that,
> but nothing seems to sort the php connection.
>
> Can anybody think of something that I have missed in this or point me to a
> suitable 'newbie' guide to debugging mysql connections so I can get all
> these sites back on line again ... If it was Firebird I'd just have mirrored
> of one of my other machines and been working as the security stuff is
> managed in the database, by mysql seems to have layers of security that I'm
> missing somewhere ;)
>
> --
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk
> Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
>
>
> --
> 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] [PHP-DEV] Separate apc-caches for each fpm-pool

2012-08-20 Thread Simon Schick
Hi, all

Not to get the bugfix https://bugs.php.net/bug.php?id=57825 too much
off-topic, I write this question in the mailinglist here:

Taking the case I have two fpm-pools on different sockets - the first
pool is responsible for www.example1.com and the second one for
www.example2.com.

If www.example1.com has 4 workers, they're all using the same
apc-cache. That's absolutely as expected. But also the workers of
www.example2.com are using this cache. In my opinion it would be nice
if the pools would have a separate cache.

I now found a solution for this: Just use more than one fpm-master
that is controlling the pools. (http://groups.drupal.org/node/198168)

Is this the way to go, or do you know of another way?
Should this be added to the APC- or fpm-documentation or is it enough
that you can find f.e. it using Google, if you need it?

Bye
Simon

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



Re: [PHP] OT (maybe not): Drupal vs WordPress

2012-08-20 Thread Simon Schick
Hi, all

+1 for that Joomla sucks ... worked with it for a while and just got
more and more disappointed of the way they write stuff. Just look at
how complicate it is to write an extension ...

Just a bit off-toppic (since you're talking about WP vs Drupal), but I
use Wordpress for small blogs and pages where I know that people don't
have that much experience with creating webpages and so on and need
very simple systems,
and TYPO3 for more complex pages (multiple domains, multi language,
complex submenus) because the system has it's own
configuration-language (TypoScript) that this let you do so many
things, way faster than writing it down in PHP. Another good bonus is
that you can decide to hide each single checkbox, inputfield or even
selections in a selectbox in the backend for an average person
administrating the web-content.

But because of the own configuration-language the learning-curve of
TYPO3 is (in my opinion) the highest of all CMS-systems for
developers.

One thing I also really like at the TYPO3-philolsophy: If someone
finds a security-issue he should immediately get in contact with the
developers (of the extension and the TYPO3 security team) and discuss
the issue with them. They decide how critical the bug is and will do a
hard work to get the fix as soon as possible. If it is a very critical
issue (someone could gain admin-access by something) they will send
out an email that there will be a bugfix coming out at next-coming day
at 9 o'clock GMT and everyone is advised to update his TYPO3-core or
the extension. This is something I really like! To be prepared for
some critical fix and knowing that (in a perfect case) no-one should
have heard about that issue before who wants to hack my website :)

Don't know if there's some similar security-policy in other
communities than this :)

Bye
Simon

On Sun, Aug 19, 2012 at 11:39 PM, Michael Shadle  wrote:
>
> If you are going to use something like joomla, use Drupal. Why bother.
> Drupal is trending up and is used by large companies and governments. Joomla
> is hokey. Yes this is going to spawn a religious debate. But joomla sucks.
> Sorry folks.
>
> --
> 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] Mac 10.7 Install/Copy fresh PHP over Pre-Installed PHP

2012-07-31 Thread Simon J Welsh
On 31/07/2012, at 10:54 PM, Jason Pruim  wrote:
> On Jul 30, 2012, at 12:01 PM, "JeffPGMT"  wrote:
> 
>> Thanks All, now I have to tell the business owner to let the IT guy update 
>> to 10.8 if he likes, which will buy me time to sort out all of what you 
>> folks contributed.
>> 
>> I wasn't aware that Mamp free installed anything more than basic and Yes, 
>> setup so that Apache, MySql and PHP work well together was what I had wanted 
>> to learn using the stock install and was able to do w/exception of imap 
>> being available.
>> 
>> Perhaps I will install XCode as it's the law of worst case probably will 
>> occur if I don't, that is I'll need it in a pinch later on.
>> 
>> JeffPGMT...
>> 
> 
> Hey Jeff,
> 
> Unless its changed in mt lion, you will need to install Xcode to use make or 
> any other program assembler...
> O

You can download just the command line tools from 
https://developer.apple.com/downloads, which is ~100 MB instead of a couple of 
gigs. Has been like this for some time now. You just have to be careful with 
some older code not compiling properly with LLVM.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Regex

2012-07-27 Thread Simon Dániel
#[0-9a-zA-Z,.]#

2012/7/27 Ethan Rosenberg 

> Dear list -
>
> I've tried everything  and am still stuck.
>
> A regex that will accept numbers, letters, comma, period and no other
> characters
>
> Thanks.
>
> Ethan Rosenberg
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


RE: [PHP] Entry point of an MVC framework

2012-07-12 Thread Simon Griffiths
I totally disagree with this!   (more exclamation marks) ! (see)
!!! (and some more) !

Learning how to put design patterns into practice in your chosen language is
a great skill to have as a programmer.  I personally use various frameworks,
however the existence of them does not stop me wanting to build my own,
learn my own way and face the problems of other framework designers and
attempt to understand the problem and how it was solved.  

To me MVC is one of those and cracking it on your own is a great way to
continue learning the language and all it has to offer.

-Original Message-
From: Daevid Vincent [mailto:dae...@daevid.com] 
Sent: 12 July 2012 22:44
To: php-general@lists.php.net
Subject: RE: [PHP] Entry point of an MVC framework

> -Original Message-
> From: Simon Dániel [mailto:simondan...@gmail.com]
> Sent: Thursday, July 12, 2012 1:21 PM
> Subject: [PHP] Entry point of an MVC framework
> 
> I have started to develop a simple MVC framework.

Yeah! Just what PHP needs, another MVC framework

NOT.

Why are you re-inventing the wheel?

Personally I *hate* frameworks with a passion, but if you're going to use
one, then why not just build with one that is already out there and well
supported. http://www.phpframeworks.com/ to start with.


--
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] Entry point of an MVC framework

2012-07-12 Thread Simon Dániel
Hi,

I have started to develop a simple MVC framework.

I have a base controller class which is abstract and all of the
controllers are inherited from that. Every controller contains actions
represented by methods. (E. g. there is a controller for managing
product items in a webshop, and there are seperate actions for create,
modify, remove, etc.) There is also a default action (usually an index
page), which is used when nothing is requested.

But what is the best way to invoke an action? I can't do it with the
baseController constructor, becouse parent class can't see inherited
classes. And I can't do it with the constructor of the inherited
class, becouse this way I would overwrite the parent constructor. And
as far as I know, it is not a good practice to call a method outside
of the class, becouse the concept of operation of the class should be
hidden from the other parts of the application.

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



Re: [PHP] [PHP-DEV] SQLite - Unwanted values using group-by

2012-07-10 Thread Simon Schick
On Sun, Jul 8, 2012 at 12:33 AM, Matijn Woudt  wrote:
>
> Both of the results are valid outcomes. I think you don't understand
> the GROUP BY clause well enough. The parameters in the SELECT clause,
> should be either
> 1) an aggregate function (like the max function you're using)
> 2) one of the parameters in the GROUP BY clause.
> If not one of the above, it will return 'random' values for r.month
> and r.year. (probably the first it finds, which might differ in your
> test cases)
>
> - Matijn

Hi, Matijn

But I think you get what I mean, when I say that max() should only
point to one row, in this case the one with the latest date ;)
How is it possible to, for sure, get the data of this rows?

Btw: Here's someone talking about that ... Out of reading this, it
should work as expected.
http://stackoverflow.com/questions/1752556/is-it-safe-to-include-extra-columns-in-the-select-list-of-a-sqlite-group-by-quer#answers

Bye
Simon

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



[PHP] [PHP-DEV] SQLite - Unwanted values using group-by

2012-07-07 Thread Simon Schick
Hi, All

May you have an idea ...

Here's the full code-example:
http://viper-7.com/M5mldG

I have the following SQL command:

SELECT max(r.month+r.year*100), r.year, r.month
FROM base b LEFT JOIN remote r ON b.id = r.remote_id
GROUP BY r.remote_id

Now I expect that the first column in the results should look like a
combination of the second and third one .. so f.e. this:
array(3) { ["max(r.month+r.year*100)"]=> string(6) "201201" ["year"]=>
string(4) "2012" ["month"]=> string(2) "01" }

But instead I get this result:
array(3) { ["max(r.month+r.year*100)"]=> string(6) "201201" ["year"]=>
string(4) "2011" ["month"]=> string(2) "12" }

I tested it on Windows7 (PHP 5.4.4, SQLiteLib v3.7.7.1), where I get the
result as shown above ... and I've also tested it on a fresh installation
on LinuxArch (PHP 5.4.4 and SQLiteLib v3.7.13) - where it works as
expected! A college of mine has tested it on OSX (PHP 5.3.7 and SQLiteLib
v3.7.13) and he gets the same result as I on the windows version.
Someone of you have an idea?
Maybe had the same problem before ... what could it be?

I thought it might a problem of the SQLite-lib but both, the LinuxArch and
the OSX system, have the same SQLite version - and both, the windows and
the LinuxArch version, have the same PHP-version.

Even if the example just uses PDO, I've also tested this using the native
SQLite3 lib and I got at least the same result on Windows. Haven't tested
the other systems with the native SQLite3 lib.

Bye
Simon


Re: [PHP] What's happened to our newsgroup?

2012-06-26 Thread Simon J Welsh

On 27/06/2012, at 9:45 AM, Daniel Brown wrote:

> On Tue, Jun 26, 2012 at 5:42 PM, Matijn Woudt  wrote:
>> 
>> Isn't everyday friday in summer? ;)
> 
>If it is, then it could be argued that every day is a Monday in
> winter --- and right now, those poor folks in the southern hemisphere
> (I'm looking at you, Thiago Pojda) are in a season of endless Mondays.
> 
> -- 
> 


So glad I take Mondays off then.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] reload page without use header

2012-06-17 Thread Simon Schick
Hi, Farzan

Redirecting is something you can do in a way the user doesn't see anything
(I call them server-side redirects) and in a way the user get's informed
that the url has changed (I call them client-side redirects).

What I mean with server-side (mostly called internal redirects) is if the
user requests a page, you can do stuff with mod_rewrite (in Apache) or some
equal webserver-module to call another file than requested. The user will
not get any notice about that.

Client-side redirects can be done using the HTTP-header (see
list-of-http-status<http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection>),
JavaScript (please think also about a non-js solution) and by using a HTML-Meta
tag <http://en.wikipedia.org/wiki/Meta_refresh>.
In my opinion the best way to do a redirect, where the user gets noticed
about, is the HTTP-header. This can be set f.e by your webserver or by a
php-script.

Example for PHP-script:

header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.new-url.com"; );

As far as I know, this is the only way to let other services (f.e. a
search-engine) know that this page has been moved permanently (or
temporarily) to another url.
That's the reason why I use the header-command (incl. setting the
HTTP-Status explicitly). If you don't set the HTTP-header, it will be added
(by PHP or your webserver). In my case, I use PHP 5.4 and nginx 1.2.1, the
header-code 302 is added if I don't set it.

May there are more ways to set redirects, but this are the one I know of.

Bye
Simon

On Sun, Jun 17, 2012 at 10:06 AM, Farzan Dalaee wrote:

> hi guys
> is there any way to reload page without using header('location
> :index.php'); and javascript?
> Best Regards
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Searching IDE.

2012-06-13 Thread Simon Dániel
Hi,

Although it's not an IDE, it is full of very useful developer tools: Kate


2012/6/13 David Arroyo 

> Hi Folks,
>
> I am searching an IDE for php and web development, my options are
> Aptana or Eclipse+PDT.
> What is your opinion?
>
> Thanks.
> Regards.
>
> --
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Searching IDE.

2012-06-13 Thread Simon Schick
Hi,

There was a discussion about that on Google+ ...

IDEs mentioned there:

__Free
* Eclipse PDT (5x)
* Aptana - based on Eclipse but not using PDT for PHP (2x)
* Netbeans (12x)
* VIM (6x)
* KDevelop (1x)
* gedit (3x)

__NonFree
* Sublime Text 2 (6x) - USD $59
* PhpStorm (7x) - €94 personal, €189 commercial
* Komodo (2x) - $382
* Zend Studio - also based on Eclipse (1x) - €299

Just by a rough view over the comments, not really reading any of those :)

My personal opinion:
* Eclipse PDT
** not used since 2008
** was way to slow, specially the file-search
** missed some good PHP code support ... code-completion for classes and
it's functions was quite limited at that time

* Netbeans
** not used since 2009
** seemed as the best free IDE for PHP to me

* Zend Studio
** not used since 2008
** seemed to be Eclipse PDT with some extensions ..

* PhpStorm
** Costs a bit of money but it's really worth it.
** intelligent code-completion
** view class-structure as UML
** helper for refactoring
** supports changelists and has it's own stash
** just faster than Netbeans and Eclipse ..

That's how I used this programs. Netbeans, Eclipse PDT and PhpStorm have
way more features but this is what I used the time I tested them.

I personally would use PhpStorm if you have money - else Netbeans.

Bye
Simon

On Wed, Jun 13, 2012 at 11:54 AM, Lester Caine  wrote:

> David Arroyo wrote:
>
>> I am searching an IDE for php and web development, my options are
>> Aptana or Eclipse+PDT.
>> What is your opinion?
>>
>
> I'm using Eclipse with PHPEclipse but PDT is probably just as good
> nowadays. PHPEclipse needs a few updates to handle some of the 'new
> features' in PHP.
>
> The advantage of Eclipse is that ALL of my development work is done in the
> one IDE, so I can play with C/C++, Python, javascript and even occasionally
> Java without having to switch. It also runs transparently on both Linux and
> Windows platforms which I have to support ...
>
> Need to fire up the java side again and have a look at fixing PHPEclipse ;)
>
> --
> Lester Caine - G8HFL
> -
> Contact - 
> http://lsces.co.uk/wiki/?page=**contact<http://lsces.co.uk/wiki/?page=contact>
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - 
> http://www.firebirdsql.org/**index.php<http://www.firebirdsql.org/index.php>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Which workstation????

2012-06-11 Thread Simon Schick
Hi, All

There was an interesting talk on the PHP Conference Spring 2012:
Concepts of Success: Choose Your Framework
http://phpconference.com/2012spring/keynotes#session-3

If somebody has been there, please write some notes ... I personally
haven't had the time to join but am quite interested, what the developer of
the frameworks say about their own systems in comparison to others. Pro and
(more interesting) Contra arguments.

The only stuff I found is in german and quite limited:
http://it-republik.de/php/artikel/FLOW3-Zend-Symfony-Auf-der-Suche-nach-dem-besten-Framework-4826.html

Bye
Simon

On Tue, Jun 5, 2012 at 2:22 PM, Simon Schick wrote:

> Hi, Farzan
>
> I do not really get your point of confusion ...
>
> What you've posted here are tools/frameworks that do not to the same stuff
> at all, yes you could even use all without missing something ...
>
> cakephp
> .. is a full-stack PHP-Framework. Yes, I have to say that there's quite a
> bunch of full-stack frameworks in PHP you could choose and I myself would
> recommend one by knowing how much experience you have in PHP :)
>
> smarty
> .. is a template-engine for PHP. If you want to use smarty, twig, php
> itself or another library as template-engine is up to you. Using a
> template-engine for some programmers I know just feel like a better
> separation between the view and the controler/model (search for
> ModelViewControler if you don't know what I mean here).
>
> netbeans
> .. is an IDE where you can develop with. I prefer to use PhpStorm, others
> use EclipsePDT, Notepad++ or even the basic editor of windows. This is just
> about syntax-highlight, code-completion and other things helping you to
> develop your code.
>
> Hope that helps :)
>
> Bye
> Simon
>
>
> On Tue, Jun 5, 2012 at 2:10 PM, Farzan Dalaee wrote:
>
>> hi guys
>> i really confuse by choosing the best work station for php ( cakephp ,
>> smarty , net bean , ... ) , please give me some advisdes.
>> and please tell why which one is better,
>> tnx
>> best regards farzan
>
>
>


Re: [PHP] Which workstation????

2012-06-05 Thread Simon Schick
Hi, Farzan

I do not really get your point of confusion ...

What you've posted here are tools/frameworks that do not to the same stuff
at all, yes you could even use all without missing something ...

cakephp
.. is a full-stack PHP-Framework. Yes, I have to say that there's quite a
bunch of full-stack frameworks in PHP you could choose and I myself would
recommend one by knowing how much experience you have in PHP :)

smarty
.. is a template-engine for PHP. If you want to use smarty, twig, php
itself or another library as template-engine is up to you. Using a
template-engine for some programmers I know just feel like a better
separation between the view and the controler/model (search for
ModelViewControler if you don't know what I mean here).

netbeans
.. is an IDE where you can develop with. I prefer to use PhpStorm, others
use EclipsePDT, Notepad++ or even the basic editor of windows. This is just
about syntax-highlight, code-completion and other things helping you to
develop your code.

Hope that helps :)

Bye
Simon

On Tue, Jun 5, 2012 at 2:10 PM, Farzan Dalaee wrote:

> hi guys
> i really confuse by choosing the best work station for php ( cakephp ,
> smarty , net bean , ... ) , please give me some advisdes.
> and please tell why which one is better,
> tnx
> best regards farzan


Re: [PHP] [missing] images .htaccess

2012-05-21 Thread Simon Schick
Hi, Muad

I guess that you have a cms (would be nice to name it if it's not a
custom one) that handles all requests coming into the system. Think
now of How you know if the requested uri is a missing-image and write
it down as mod_rewrite rule.
Is this the only line you have in your .htaccess-script? What does the
cms with the request if the file is available? Does the cms here just
works like a proxy or is it doing some other magic? May it checks some
permissions first before it ships the file?

If you want to ungo passing requests for images to the cms, I'd do it like this:
It checkes if the request is pointing to a directory where only images
(or downloadable files) are located and lets apache do the rest to
provide the file. Or check for file-endings ...

RewriteRule \.(gif|jpg|jpeg|png)$ - [L]

You can then guess that all files ending with .jpeg, .jpg, .gif, .png
or similar are pictures, bypass the cms and let apache ship the file
or apaches 404-page if not available.
But this has nothing to do with PHP itself but is an apache-configuration.
Here's a beginner guide where I copied the line above:
http://www.workingwith.me.uk/articles/scripting/mod_rewrite

Bye
Simon

On Mon, May 21, 2012 at 5:55 PM, muad shibani  wrote:
>
> Hi there
>
> how I can ignore [missing]  images and other files completely in .htaccess
>  from being processed by the index.php file
>
>
>
> RewriteRule .* index.php [L]
>
> the CMS itself gives 404 error page for unknown request
>
> thanks in advance

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



Re: [PHP] requesting comments on rajmvServiceLog (access + error logging through PHP and JS to MySQL)

2012-05-21 Thread Simon Schick
Hi, Rene

I took a quick look over your code ...

I kind-of like the idea having all logging at one place, but the code is a
bit too messy if you ask me :)
If you would have put it on github and I would fork it - the first thing
I'd do is trying to get rid of the hm-lib and rewriting all in a bit more
object-oriented style, but that's just personal taste ;)
Specially the function rajmvServiceLog_graphs_raphael_calculateData() with
a code of ca. 280 lines is quite long ...
Additionally I think that setting an error-handler who's just returning
false is not a good way. Why not disable error-handling or write code that
produces no errors?

I think it would be good to mention that you're using the library adodb (
http://adodb.sourceforge.net/) and sitewide_rv (is it that?
http://mediabeez.ws/) or am I guessing wrong?

You're talking about a sql-file ... has my anti-virus-program removed
something here?

Please don't see that as destructive critic, but as hints what I would do
if I get to do with this code.

Bye
Simon

On Mon, May 21, 2012 at 12:46 PM, rene7705  wrote:

> Hi.
>
> I wasn't happy with the fact that Google Analytics doesn't record many
> of the hits on my sites, so I decided to roll my own analytics
> software, and opensource it.
> It's now in a state where I can request early comments.
> You can view a demo at http://mediabeez.ws/stats (under construction,
> may fail at times) (browser compatibility may be an issue, I built it
> with chrome, should work in firefox too, but won't (ever) in IE.)
> If you click on the graph while the details for a given day are
> visible, you will see the errors for that day in a DIV below the
> graph.
>
> Normally you'd hide the error details and $hits for anyone's who's not
> registred as a developer, of course. I've turned it on for all at the
> moment, so you can comment on that feature and review my results array
> $hits.
>
> I've opted, for simplicity of design, to store all settings I thought
> could be remotely interesting in a mysql db (see attached sql init
> file) (which is filled from PHP every time a page is delivered, and
> again from JS when the page has initialized fully, or does a HTML5
> History API location.href change), and then use PHP to retrieve all
> rows for a given datetime-range, and do the totals calculations in a
> php loop.
> I'm only keeping 1 row from the db in memory at any given time, but
> I'm building up a large deep array with the totals information in the
> php loop that goes over the rows.
> I'm wondering if this is a good approach, though. Maybe I should let
> the totals be calculated by the mysql server instead.
>
> I was thinking to let the totals calculations stay in php, and be
> executed from a cron job every hour. Only for the current month would
> you need to re-calculate every hour.
> I haven't figured out yet how to for instance only re-calculate the
> last hour, store results per hour, and then calculate the day and
> month totals from that "hourly cache" data when needed.
> I don't have a clue about how big companies do their totals
> calculations (for sites that get way more hits than mine, which is
> something i'd like to be able to support with my own analytics code),
> and would like to know how big companies do this.
>
> I've included the relevant draft code as attachment files to this
> mail, for your review. Please let me know if I have forgotten to
> include relevant code..
>
> As always, thanks for your time,
>  Rene
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


Re: [PHP] errors not showing

2012-05-19 Thread Simon J Welsh
On 20/05/2012, at 3:55 PM, Tim Dunphy wrote:

> hello, list!
> 
> I have 'error_reporting = E_ALL' set in my php.ini file. However when
> I run a php script that has errors in it all that happens is that the
> page WSODs. I am running Mac OS X 10.6. Any thoughts on why errors
> don't show up in the browser and how to correct this?
> 
> 
> Thanks
> Tim

You also need to set display_errors to On.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] IDE

2012-05-06 Thread Simon Schick
On Mon, May 7, 2012 at 3:10 AM, Ethan Rosenberg  wrote:
>
>
> ===
> Simon -
>
> Thanks.
>
>
>> I don't think you're talking about auto-form-fill and stuff like
>> that, are you?
>
>
> No, I am not.
>
> Please send me your xdebug-config file.
>
> Thanks
>
> Ethan
>
>

Hi, Ethan

I forgot to mention that the whole configuration of my test-webserver
is on github ;) There are my configuration-files for apache, mysql,
nginx, php, solr and so on.
But I have to say that my environment is a bit special as I am
developing on a windows-machine and this configuration is running on a
virtual linux machine. Don't hesitate to ask things about the
configuration :)
https://github.com/SimonSimCity/webserver-configuration
For each program I have an init.sh script which will install the
program exactly the way I use it.
Feel free to fork it and add your stuff.

If you're just looking for the xdebug-configuration:
https://github.com/SimonSimCity/webserver-configuration/blob/master/php/conf/conf.d/xdebug.ini
You might have to change it to use it on a windows-environment ... at
least you'd have to move it into your php.ini file instead of an
separate configuration-file as it is on Linux.

As I am the only one developing on this machine, I've configured
xdebug in that way, that anyone can open a xdebug-debug-session. This
is done by enabling xdebug.remote_connect_back. Please do not use this
on your live-server, but set an ip-limit using xdebug.remote_host!

Please read this part of the xdebug-configuration to get a better
understanding on how to set up a working environment (specially the
part "Starting The Debugger"):
http://xdebug.org/docs/remote

The only problem I can report so far is, that I can't debug
command-line scripts ... If someone else reading that post has an
answer, I'd be glad to hear it.

Bye
Simon

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



Re: [PHP] IDE

2012-05-06 Thread Simon Schick
On Mon, May 7, 2012 at 12:33 AM, Ethan Rosenberg  wrote:
>
> Dear List -
>
> Is there any IDE which will let me step thru my code AND give the
> opportunity to enter data; eg, when a form should be displayed allow me to
> enter data into the form and then proceed?  I realize the forms are either
> HTML and/or Javascript, but there must be a work-around.  I is exceedingly
> tedious to use echo print var_dump print_r.
>
> Thanks.
>
> Ethan
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Hi, Ethan

The only thing I can come up with, that would really help you, since
you're just working with var_dump and print_r, is a php-debugger.

The common debugger for php are Zend Debugger and xdebug.

Nearly every IDE can be connected to them and if you set it up
correctly you can browse through your side (using your favourite
browser) and activate the debugger just by setting a cookie. For
several browsers there are plugins that set the cookie by clicking an
icon.
I'm talking about "nearly every IDE" because I saw a screenshot of
someone debugging a php-script using xdebug and vi :)

Just the first two links I found on google ...
* http://xdebug.org/docs/install
* 
http://www.thierryb.net/pdtwiki/index.php?title=Using_PDT_:_Installation_:_Installing_the_Zend_Debugger

Is that what you need?

I'm personally using PhpStorm and a VM with Debian, PHP 5.3 and xdebug
to debug my scripts and am perfectly fine with that. I can send you my
whole xdebug-config if you want :)

The stuff with javascript sounds like something automated to me ...
But I don't think you're talking about auto-form-fill and stuff like
that, are you?

Bye
Simon

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



Re: [PHP] function

2012-05-03 Thread Simon Schick
On Fri, May 4, 2012 at 4:29 AM, Dan Joseph  wrote:
>
> Are these inside classes or anything?  If they're just functions, they
> should work fine together, example of 2 working functions together:
>
> 
> hellotwo();
>
> function helloone()
> {
>        echo "hi 1";
> }
>
> function hellotwo()
> {
>        helloone();
> }
>
> ?>
>
> This results in "hi 1" being echoed to the screen.
>
> --
> -Dan Joseph
>
> http://www.danjoseph.me

Hi, Ron

Another hint:
Maybe the other function (you want to call inside your first function)
is not defined at that time but in a file that's included later on ...

Bye
Simon

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



Re: [PHP] Should I check imput for bad chars in this case?

2012-04-26 Thread Simon Schick
On Thu, Apr 26, 2012 at 3:59 PM, mirrys.net  wrote:
> Thank you for your help Marco & Simon. No doubt, your code is much
> cleaner and better.
>
> One more question, without any filter or something could be my
> original code somehow compromised (mean some security bug)? Or rather
> was a major problem in the possibility of a script crash?
>

Hi, Mirrys

I personally can not see a security-hole at the first view ...
Stuff in the global server-variable should only be set by the
webserver and therefore it should be kind-of save (depending on the
quality of the configuration of the webserver ;))

That was also the main reason why I would do a validation-check for this.
Talking about a script-crash ... I don't know ... I just found this
line in a comment for the function gethostbyaddress()

> If you use gethostbyaddr() with a bad IP address then it will send an error 
> message to the error log.

Bye
Simon

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



Re: [PHP] Should I check imput for bad chars in this case?

2012-04-26 Thread Simon Schick
On Thu, Apr 26, 2012 at 2:15 PM, mirrys.net  wrote:
> Hi all,
>
> this is more question than real problem (I hope :)). I include this
> script into my pages to log IPs of visitors (they are saved info txt
> file and send to e-mail later):
>
> function getIPadress()
> {
>    if (isset($_SERVER["HTTP_CLIENT_IP"]))
>    {
>        return $_SERVER["HTTP_CLIENT_IP"];
>    }
>    elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
>    {
>        return $_SERVER["HTTP_X_FORWARDED_FOR"];
>    }
>    elseif (isset($_SERVER["HTTP_X_FORWARDED"]))
>    {
>        return $_SERVER["HTTP_X_FORWARDED"];
>    }
>    elseif (isset($_SERVER["HTTP_FORWARDED_FOR"]))
>    {
>        return $_SERVER["HTTP_FORWARDED_FOR"];
>    }
>    elseif (isset($_SERVER["HTTP_FORWARDED"]))
>    {
>        return $_SERVER["HTTP_FORWARDED"];
>    }
>    else
>    {
>        return $_SERVER["REMOTE_ADDR"];
>    }
> }
>
> // save log to txt
> $fh = fopen($fileWithLog, 'a+') or die("Oups " . $fileWithLog ." !");
> $IPAdress = getIPadress();
> fwrite($fh, date('j.n.Y G:i:s') . $IPAdress . " (" .
> gethostbyaddr($IPAdress) . ")\n");
> fclose($fh);
>
> ...can this be some possible security risk (XSS or so..), becose I
> does not check chars in IP adress and host name mainly. It is probably
> crazy, but on the other side I think it isn't imposibble to use some
> bad strings in host name.
>
> Would you recommend use "$IPAdress = htmlspecialchars(getIPadress());"
> or something like? Or is it nonsense?
>
> Thx and excuse me, if this question is too stupid :(. Br, Mir R.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Hi, mirrys

Why not use the function filter_input()? This would be at least show
if the value is a valid ip-address.

function getIPadress() {
$params = array(
"HTTP_CLIENT_IP",
"HTTP_X_FORWARDED_FOR",
"HTTP_X_FORWARDED",
"HTTP_FORWARDED_FOR",
"HTTP_FORWARDED",
"REMOTE_ADDR"
);

foreach($params as $param) {
if ($val = filter_input(INPUT_SERVER, $param, 
FILTER_VALIDATE_IP))
    return $val;
}

return false;
}

This way you could even specify "I don't want ip's out of a private
range" and stuff like that ...
http://www.php.net/manual/en/filter.filters.validate.php
http://www.php.net/manual/en/function.filter-input.php

If no valid ip-address is found you'll get false here ... depends -
may you want to give "127.0.0.1" back then ;)

Bye
Simon

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



Re: [PHP] Best PHP Template System

2012-04-26 Thread Simon Schick
On Thu, Apr 26, 2012 at 12:07 AM, Yared Hufkens  wrote:
>
> Why use an external engine which slows your scripts down to do something
> which can easily be done by PHP itself? PHP is imho the best template engine
> for PHP.
> With PHP 5.4, it became even easier because somestuff()?> can be
> used without short_open_tag enabled.
> However, you always schould divide UI and backend.
>

Hi,

If you like to write an xml-template by having purely xml, you could
also use OPT (Open Power Template).

You can f.e. add a attribute to a tag by decision by writing this code:



Content


Feels a bit cleaner to me than writing

class="highlight">
Content


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



Re: [PHP] date() confustion

2012-04-25 Thread Simon J Welsh
On 26/04/2012, at 4:40 PM, Nathan Nobbe wrote:

> Hi everyone,
> 
> Does anybody know what might influence the output of the date() function
> besides date.timezone setting?
> 
> Running through some code in an app I'm working on, I have this code:
> 
> $timestamp = time();
> $mysqlDatetime = date("Y-m-d G:i:s", $timestamp);
> 
> Logging these values yields:
> 
> INSERT TIMESTAMP:  1335414561
> INSERT DATE TIME:  2012-04-26 4:29:21
> 
> But then from the interactive interpreter on the same box (same php.ini as
> well):
> 
> php > echo date("Y-m-d G:i:s", 1335414561);
> 2012-04-25 22:29:21
> 
> I get this same output from another random computer of mine and I've
> verified date.timezone is consistent in both environments.
> 
> Something's going on in the first case, but I'm unsure what; any ideas?
> 
> Your help appreciated as always.
> 
> -nathan


A call to date_default_timezone_set() during execution can change the timezone. 
If you add echo date_default_timezone_get(); just before this, does it give the 
same output as your date.timezone setting?

---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] PHP: a fractal of bad design

2012-04-12 Thread Simon Schick
2012/4/12 Daevid Vincent :
> http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
>
> Can't say he doesn't have some good points, but he sure goes about it in a
> dickish way.

Hi, Daevid

I think this discussion is incomplete without mentioning the feedback
from Anthony Ferrara:
http://blog.ircmaxell.com/2012/04/php-sucks-but-i-like-it.html

Bye
Simon

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



Re: [PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-04-02 Thread Simon
On 2 April 2012 22:25, Stuart Dallas  wrote:

> On 2 Apr 2012, at 15:37, Simon wrote:
>
> > On 2 April 2012 14:27, Stuart Dallas  wrote:
> >> On 2 Apr 2012, at 14:12, Simon wrote:
> >>
> >> > Thanks Maciek
> >> >
> >> > On 2 April 2012 10:37, Maciek Sokolewicz  >wrote:
> >> >
> >> >> On 02-04-2012 10:12, Simon wrote:
> >> >>
> >> >>> Thanks Simon. you got my hopes up there for a second.
> >> >>>
> >> >>> From the php docs page:
> >> >>>
> >> >>> Critics further argue that it is pointless to use a Singleton in a
> Shared
> >> >>>>
> >> >>> Nothing Architecture like PHP where objects are unique>within the
> Request
> >> >>> only anyways.
> >> >>>
> >> >>> I want the the singleton class to be global to the entire
> application (ie
> >> >>> shared "by reference" across all requests). I'd agree with the above
> >> >>> critics that if you have to instantiate your singleton for each
> request,
> >> >>> it's rather pointless.
> >> >>>
> >> >>> Well, that's simply not possible due to the "shared nothing
> paradigm".
> >> >> If you want to share, you need to either share it via another medium
> (such
> >> >> as a database, as has been suggested a dozen times already) or
> switch to a
> >> >> different language.
> >> >
> >> >
> >> >
> >> >> PHP is based on this paradigm, and you should not expect of it to
> violate
> >> >> it just because you want to do things a certain way, which is not
> the PHP
> >> >> way.
> >> >>
> >> >
> >> > The existence of memcached, shm and apc_fetch tell me that PHP already
> >> > accepts the need for sharing data between processes. All I'm arguing
> for is
> >> > the ability to share the data by reference rather than by copy.
> >>
> >>
> >> As already mentioned several times the closest you will get is shared
> memory (as used by APC), but you can't access that by reference because
> shared read/write resources need controlled access for stability.
> >
> > I know. I understand that (and the issues with locking that might arise
> if truly shared memory was available).
> >
> >> I can't find any material that explains how the .net framework
> implements application variables. You mentioned earlier that you *know*
> that when you access them you do so by reference. Do you have a source for
> this knowledge or is it some sort of sixth sense?
> >
> > Source: 10+ years as an ASP and ASP.NET developer.
>
> Wow. As knowledge goes that's up there with "I believe it therefore it is."
>

I don't understand your point.


>
> > Having looked for documentation, I agree, it's utterly terrible. It's as
> if even Microsoft themselves don't fully understand the advantages that
> application variables give them over the competition. (Though they're
> hardly likely to be forthcoming about helping others implement similar
> features).
> >
> > Here's some stuff I did find:
> >
> >
> http://www.codeproject.com/Articles/87316/A-walkthrough-to-Application-State#e
> > This article explains basically how application variables work. It
> doesn't specifically mention passing by reference but it discusses thread
> safety at some length so you might infer that implies passing by reference.
>
> "can cause performance overhead if it is heavy"
>

You certainly have to be careful how you use it (as you do any tool).

| And you want to store petabytes of data in there. Smart.

No, I want to store 50 - 200Mb.
At some point in the somewhat distant future I can imagine larger amounts
of shared storage between required. Up to and including petabytes of data
when such large amounts of RAM become practical.

This does not have to cause overhead. The author was suggesting caution to
protect people who aren't sure what they're doing. This can be done with
"no" performance overhead (so long as you have the physical RAM).


>
> Anyway, that page says nothing about whether it's accessed by reference.
> It implies that writes are atomic, which in turn implies that there is
> something in the background controlling write access to the data.
>
> As for reading the data being done via references there is nothing in that
> article 

Fwd: [PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-04-02 Thread Simon
On 2 April 2012 14:27, Stuart Dallas  wrote:

> On 2 Apr 2012, at 14:12, Simon wrote:
>
> > Thanks Maciek
> >
> > On 2 April 2012 10:37, Maciek Sokolewicz  >wrote:
> >
> >> On 02-04-2012 10:12, Simon wrote:
> >>
> >>> Thanks Simon. you got my hopes up there for a second.
> >>>
> >>> From the php docs page:
> >>>
> >>> Critics further argue that it is pointless to use a Singleton in a
> Shared
> >>>>
> >>> Nothing Architecture like PHP where objects are unique>within the
> Request
> >>> only anyways.
> >>>
> >>> I want the the singleton class to be global to the entire application
> (ie
> >>> shared "by reference" across all requests). I'd agree with the above
> >>> critics that if you have to instantiate your singleton for each
> request,
> >>> it's rather pointless.
> >>>
> >>> Well, that's simply not possible due to the "shared nothing paradigm".
> >> If you want to share, you need to either share it via another medium
> (such
> >> as a database, as has been suggested a dozen times already) or switch
> to a
> >> different language.
> >
> >
> >
> >> PHP is based on this paradigm, and you should not expect of it to
> violate
> >> it just because you want to do things a certain way, which is not the
> PHP
> >> way.
> >>
> >
> > The existence of memcached, shm and apc_fetch tell me that PHP already
> > accepts the need for sharing data between processes. All I'm arguing for
> is
> > the ability to share the data by reference rather than by copy.
>
>
> As already mentioned several times the closest you will get is shared
> memory (as used by APC), but you can't access that by reference because
> shared read/write resources need controlled access for stability.
>

I know. I understand that (and the issues with locking that might arise if
truly shared memory was available).


>
> I can't find any material that explains how the .net framework implements
> application variables. You mentioned earlier that you *know* that when you
> access them you do so by reference. Do you have a source for this knowledge
> or is it some sort of sixth sense?
>

Source: 10+ years as an ASP and ASP.NET developer.

Having looked for documentation, I agree, it's utterly terrible. It's as if
even Microsoft themselves don't fully understand the advantages that
application variables give them over the competition. (Though they're
hardly likely to be forthcoming about helping others implement similar
features).

Here's some stuff I did find:

http://www.codeproject.com/Articles/87316/A-walkthrough-to-Application-State#e
This article explains basically how application variables work. It doesn't
specifically mention passing by reference but it discusses thread safety at
some length so you might infer that implies passing by reference.

http://msdn.microsoft.com/en-us/library/ff650849.aspx
Here is a more technical discussion about the singleton class is
implemented in .NET. Application variables are provided by an instance of a
singleton class (the HttpApplication class).

http://stackoverflow.com/questions/1132373/do-asp-net-application-variables-pass-by-reference-or-value
Stack overflow question from someone actually wanting to get a *copy* of an
application variable rather than a reference.

So, if you read enough of this stuff, you'll find out that a .NET website
(an IIS application in MS parlance) runs in a multi-threaded single
process. Application variables (and singleton classes) are shared by
reference between all threads. It is possible to run an IIS application
over multiple processes (to take advantage of multiple processors / server
farms for example) but then the Application variables are not shared at
all. (This is then pretty comparable to the situation with node.js except
that node is not multi-threaded)






>
> I would not feel comfortable having my code creating multiple pointers to
> a read/write segment of shared memory that then uncontrollably float around
> umpteen processes. If MS have something akin to this in .net I would be
> extremely interested in reading about how it works without imploding.
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>


Re: [PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-04-02 Thread Simon
Thanks Maciek

On 2 April 2012 10:37, Maciek Sokolewicz wrote:

> On 02-04-2012 10:12, Simon wrote:
>
>> Thanks Simon. you got my hopes up there for a second.
>>
>>  From the php docs page:
>>
>>  Critics further argue that it is pointless to use a Singleton in a Shared
>>>
>> Nothing Architecture like PHP where objects are unique>within the Request
>> only anyways.
>>
>> I want the the singleton class to be global to the entire application (ie
>> shared "by reference" across all requests). I'd agree with the above
>> critics that if you have to instantiate your singleton for each request,
>> it's rather pointless.
>>
>>  Well, that's simply not possible due to the "shared nothing paradigm".
> If you want to share, you need to either share it via another medium (such
> as a database, as has been suggested a dozen times already) or switch to a
> different language.



> PHP is based on this paradigm, and you should not expect of it to violate
> it just because you want to do things a certain way, which is not the PHP
> way.
>

The existence of memcached, shm and apc_fetch tell me that PHP already
accepts the need for sharing data between processes. All I'm arguing for is
the ability to share the data by reference rather than by copy.


>
> - Tul
>
>


Re: [PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-04-02 Thread Simon
Thanks Simon. you got my hopes up there for a second.

>From the php docs page:

>Critics further argue that it is pointless to use a Singleton in a Shared
Nothing Architecture like PHP where objects are unique >within the Request
only anyways.

I want the the singleton class to be global to the entire application (ie
shared "by reference" across all requests). I'd agree with the above
critics that if you have to instantiate your singleton for each request,
it's rather pointless.

On 2 April 2012 07:54, Simon Schick  wrote:

> 2012/4/1 Simon 
> >
> > Another thing that's possible in .NET is the Singleton design pattern.
> > (Application variables are an implementation of this pattern)
> >
> > This makes it possible to instantiate a static class so that a single
> > instance of the object is available to all threads (ie requests) across
> > your application.
> >
> > So for example the code below creates a single instance of an object for
> > the entire "server". Any code calling "new App();"  gets a pointer to the
> > shared object.
> >
> > If PHP could do this, it would be *awesome* and I wouldn't need
> > application
> > variables since this is a superior solution.
> >
> > Can / could PHP do anything like this ?
> >
> > public class App
> > {
> >   private static App instance;
> >   private App() {}
> >   public static App Instance
> >   {
> >  get
> >  {
> > if (instance == null)
> > {
> >instance = new App();
> > }
> > return instance;
> >  }
> >   }
> > }
> >
> >
> > Creates an inste
>
> Hi, Simon
>
> Sorry for this out-of-context post - but just to answer to Simon's
> question:
>
> One way of implementing Singleton in PHP is written down in the php-manual:
> http://www.php.net/manual/en/language.oop5.patterns.php
> I personally would also declare __clone() and __wakeup() as private,
> but that's something personal :)
>
> If you have many places where you'd like to use the Singleton-pattern
> you may now think of having one class where you define the pattern
> itself and extending other classes from that ... But that does not
> seem the good way to me because this classes are not related at all,
> in case of content.
> Other frameworks are using interfaces but they have to write the code
> for the implementation over and over again.
>
> Here's where traids make the most sense to me:
>
> http://stackoverflow.com/questions/7104957/building-a-singleton-trait-with-php-5-4
>
> Bye
> Simon
>


Re: [PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-04-01 Thread Simon Schick
2012/4/1 Simon 
>
> Another thing that's possible in .NET is the Singleton design pattern.
> (Application variables are an implementation of this pattern)
>
> This makes it possible to instantiate a static class so that a single
> instance of the object is available to all threads (ie requests) across
> your application.
>
> So for example the code below creates a single instance of an object for
> the entire "server". Any code calling "new App();"  gets a pointer to the
> shared object.
>
> If PHP could do this, it would be *awesome* and I wouldn't need
> application
> variables since this is a superior solution.
>
> Can / could PHP do anything like this ?
>
> public class App
> {
>   private static App instance;
>   private App() {}
>   public static App Instance
>   {
>      get
>      {
>         if (instance == null)
>         {
>            instance = new App();
>         }
>         return instance;
>      }
>   }
> }
>
>
> Creates an inste

Hi, Simon

Sorry for this out-of-context post - but just to answer to Simon's question:

One way of implementing Singleton in PHP is written down in the php-manual:
http://www.php.net/manual/en/language.oop5.patterns.php
I personally would also declare __clone() and __wakeup() as private,
but that's something personal :)

If you have many places where you'd like to use the Singleton-pattern
you may now think of having one class where you define the pattern
itself and extending other classes from that ... But that does not
seem the good way to me because this classes are not related at all,
in case of content.
Other frameworks are using interfaces but they have to write the code
for the implementation over and over again.

Here's where traids make the most sense to me:
http://stackoverflow.com/questions/7104957/building-a-singleton-trait-with-php-5-4

Bye
Simon

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



Re: [PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-04-01 Thread Simon
>
> On 1 April 2012 13:52, Simon  wrote:
>
>>
>>
>> On 31 March 2012 20:44, Stuart Dallas  wrote:
>>
>>> On 31 Mar 2012, at 13:14, Simon wrote:
>>>
>>> > Thanks again Stuart.
>>> >
>>> > On 31 March 2012 12:50, Stuart Dallas  wrote:
>>> >> On 31 March 2012 11:19, Simon  wrote:
>>> >> Thanks for your answer.
>>> >>
>>> >> On 31 March 2012 09:50, Stuart Dallas  wrote:
>>> >> On 31 Mar 2012, at 02:33, Simon wrote:
>>> >>
>>> >> > Or: Why doesn't PHP have Applications variables like ASP.NET  (and
>>> node.js)
>>> >> > ?
>>> >> >
>>> >> > Hi,
>>> >> >
>>> >> > I'm working on optimising a php application (Drupal).
>>> >> >
>>> >> > The best optimisation I've found so far is to use APC to store
>>> various bits
>>> >> > of Drupal data in RAM.
>>> >> >
>>> >> > The problem with this is that with Drupal requiring say 50Mb of
>>> data* per
>>> >> > request is that lots of cpu cycles are wasted de-serialising data
>>> out of
>>> >> > apc_fetch. Also 50Mb of data per http process !! is wasted by each
>>> one
>>> >> > re-creating it's own copy of the shared data.
>>> >>
>>> >> 50MB? WTF is it storing?? I've never used Drupal, but based purely on
>>> that it sounds like an extremely inefficient piece of software that's best
>>> avoided!
>>> >>
>>> >> All sorts of stuff (taxonomies, lists of data, menu structures,
>>> configuration settings, content etc). Drupal is a sophisticated
>>> application. Besides, 50Mb of data seems like relatively tiny "application
>>> state" to want to access in fastest possible way. It's not hard to imagine
>>> wanting to use *much* more than this in future
>>> >>
>>> >>
>>> >> > If it were possible for apc_fetch (or similar function) to return a
>>> pointer
>>> >> > to the data rather than a copy of the data this would enable
>>> incredible
>>> >> > reduction in cpu and memory usage.
>>> >>
>>> >> Vanilla PHP adheres to a principle known as "shared nothing
>>> architecture" in which, shockingly, nothing is shared between processes or
>>> requests. This is primarily for scalability reasons; if you stick to the
>>> shared nothing approach your application should be easily scalable.
>>> >>
>>> >> Yes, I know. I think the effect of this is that php will scale better
>>> (on average) in situations where requests don't need to share much data
>>> such as "shared hosting". In an enterprise enviroment where the whole
>>> server might be dedicated to single application, "shared nothing" seems to
>>> be a synonym for "re-load everything" ?
>>> >>
>>> >> Yes, on one level that is what it means, but alternatively it could
>>> mean being a lot more conservative about what you load for each request.
>>> >
>>> > Um, I want to be *less* conservative. Possibly *much* less. (like
>>> Gigabyes or even eventually Petabytes of shared data !)
>>>
>>> We appear to have drifted off the point. There's a big difference
>>> between data that an application needs to access and "application
>>> variables".
>>
>>
>>> What you're describing is a database. If you want something more
>>> performant there are ways to optimise access to that amount of data, but if
>>> not I've completely lost what the problem is that you're trying to solve.
>>>
>>
>> Right now I have a need to store maybe 50Mb - 200Mb of data in RAM
>> between requests. I suggesteed PetaBytes as an example of how much might be
>> beneficial at some considerable point in the future to highlight how
>> relatively un-scalable "passing by copy" (ie memcached / APC) is compared
>> to application variables.
>>
>>
>>> >> > This is essentially how ASP.NET Application variables and node.js
>>> work.
>>> >>
>>> >> Not a valid comparison. Node.js applications can only share variables
>>> within a single process, and they can do so because it's single-threaded.
>>>

[PHP] Could apc_fetch return a pointer to data in shared memory ?

2012-03-30 Thread Simon
Or: Why doesn't PHP have Applications variables like ASP.NET  (and node.js)
?

Hi,

I'm working on optimising a php application (Drupal).

The best optimisation I've found so far is to use APC to store various bits
of Drupal data in RAM.

The problem with this is that with Drupal requiring say 50Mb of data* per
request is that lots of cpu cycles are wasted de-serialising data out of
apc_fetch. Also 50Mb of data per http process !! is wasted by each one
re-creating it's own copy of the shared data.

If it were possible for apc_fetch (or similar function) to return a pointer
to the data rather than a copy of the data this would enable incredible
reduction in cpu and memory usage.

This is essentially how ASP.NET Application variables and node.js work.

I'm surprised PHP doesn't already have Application variables, given that
they are so similar to Session Variables and that it's been around for a
long time in ASP / ASP.NET.

I just wondered if there was a reason for not having this functionality or
if it's on a road map somewhere or I've missed something :) ?


Re: [PHP] Watch out for automatic type casting

2012-03-29 Thread Simon Schick
Hi, Arno

FYI: I found a page in the php-manual that's exactly for that:
http://www.php.net/manual/en/language.operators.precedence.php

p.s. some of them were also new to me  Thanks for getting me to read it.

Bye
Simon

2012/3/29 Simon Schick :
> Hi, Arno
>
> I don't know if this is written somewhere in the php-manual, but I
> really like this table:
> http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages
>
> I do not really understand why this has some special stuff to do with
> typecasting ... This is just an order like the operators + and * in
> math.
> If you'd ask me, this is exactly what I would expect to happen.
>
> Bye
> Simon
>
> 2012/3/29 Arno Kuhl :
>> I found automatic typecasting can be a bit of a gotcha.
>>
>>
>>
>> $sText = "this.is.a.test.text";
>>
>> if ( $pos = strpos($sText, "test") !== FALSE) {
>>
>>                echo  substr($sText, 0, $pos)."<".substr($sText, $pos,
>> strlen("test")).">".substr($sText, $pos+strlen("test"));
>>
>> }
>>
>>
>>
>> The code seems logical enough, and the expected result would be:
>>
>> this.is.a..text
>>
>>
>>
>> In fact it ends up being:
>>
>> tis.a.test.text
>>
>>
>>
>> The reason is $pos is typecast as TRUE, not int 10, presumably because it's
>> in the same scope as the boolean test.
>>
>> Then when $pos is later used as an int it's converted from TRUE to 1.
>>
>>
>>
>> You have to bracket the $pos setting to move it into its own scope to
>> prevent it being typecast:
>>
>> if ( ($pos = strpos($sText, "test")) !== FALSE) {
>>
>>
>>
>> No doubt it's mentioned somewhere in the php manual, I just never came
>> across it.
>>
>> Just thought I'd highlight one of the gotchas of auto typecasting for any
>> other simpletons like me.
>>
>>
>>
>> Cheers
>>
>> Arno
>>

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



Re: [PHP] Watch out for automatic type casting

2012-03-29 Thread Simon Schick
Hi, Arno

I don't know if this is written somewhere in the php-manual, but I
really like this table:
http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages

I do not really understand why this has some special stuff to do with
typecasting ... This is just an order like the operators + and * in
math.
If you'd ask me, this is exactly what I would expect to happen.

Bye
Simon

2012/3/29 Arno Kuhl :
> I found automatic typecasting can be a bit of a gotcha.
>
>
>
> $sText = "this.is.a.test.text";
>
> if ( $pos = strpos($sText, "test") !== FALSE) {
>
>                echo  substr($sText, 0, $pos)."<".substr($sText, $pos,
> strlen("test")).">".substr($sText, $pos+strlen("test"));
>
> }
>
>
>
> The code seems logical enough, and the expected result would be:
>
> this.is.a..text
>
>
>
> In fact it ends up being:
>
> tis.a.test.text
>
>
>
> The reason is $pos is typecast as TRUE, not int 10, presumably because it's
> in the same scope as the boolean test.
>
> Then when $pos is later used as an int it's converted from TRUE to 1.
>
>
>
> You have to bracket the $pos setting to move it into its own scope to
> prevent it being typecast:
>
> if ( ($pos = strpos($sText, "test")) !== FALSE) {
>
>
>
> No doubt it's mentioned somewhere in the php manual, I just never came
> across it.
>
> Just thought I'd highlight one of the gotchas of auto typecasting for any
> other simpletons like me.
>
>
>
> Cheers
>
> Arno
>

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



Re: [PHP] including PHP code from another server..

2012-03-26 Thread Simon Schick
Hi, Rene

I just want to say the same ... whatever you're trying to do here - it
will end up in a major security-isse that (I think) you won't fix that
soon as someone has hacked your server.

That sounds like you don't wanna pay 10$ per month for a good
multiple-domain-hosting solution.
If you're searching for something cheap for multi-domains, take a look
at providers like DreamHost or something similar.

Bye
Simon

2012/3/26 Stuart Dallas :
> REMOVE THAT SCRIPT FROM YOUR SERVER RIGHT NOW!
>
> See follow-up email direct to you for the reason!
>
> On 26 Mar 2012, at 14:53, rene7705 wrote:
>
>> Hi.
>>
>> My last thread got derailed into a javascript and even photoshop
>> discussion, and while I can't blame myself for that really, this time I
>> would like to bring a pure PHP issue to your scrutiny.
>>
>> I run several sites now, on the same shared hoster, but with such a setup
>> that I cannot let PHP require() or include() code from a central place
>> located on another domain name on the same shared hosting account, not the
>> normal way at least.
>> $_SERVER['DOCUMENT_ROOT'] is a completely different path for each of the
>> domains on the same hosting account, and obviously you can't access one
>> domain's directory from another domain.
>>
>> Hoster support's reply is A) I dont know code, B) You can't include code
>> from one domain on another and C) use multiple copies, 1 for each domain
>>
>> But that directory (my opensourced /code in the zip on
>> http://mediabeez.wsbtw), takes a while to update to my hoster, many
>> files.
>> Plus, as I add more domains that use the same code base, my overhead and
>> waiting time increases lineary at a steep incline.
>>
>> So.. Since all of this code is my own, and tested and trusted, I can just
>> eval(file_get_contents('
>> http://sitewithwantedcode.com/code/get_php.php?file=/code/sitewide_rv/autorun.php'))
>> hehe
>> And get_php.php takes care of the nested includes by massaging what it
>> retrieves. Or so is my thinking.
>>
>> The problem I'm facing, and for which I'm asking your most scrutinous
>> feedback, is:
>> How would you transform _nested_ require(_once) and include(_once)? I
>> haven't figured out yet how to transform a relative path include/require.
>> What about for instance a require_once($fileIwantNow)?
>> I do both in my /code tree atm.
>>
>> For my own purposes, I could massage my own PHP in /code/libraries_rv and
>> /code/sitewide_rv manually, but I'd also like to be able to include a
>> single copy of the 3rd party free libs that I use in
>> /code/libraries(/adodb-5.10 for instance). And god knows how they might
>> include and require.
>>
>> Plus, I'd like to turn this into another free how-to blog entry on
>> http://mediabeez.ws, plus accompanying code, so I think I might find some
>> free tips here again.
>>
>> Greetings,
>> from spring sun soaked amsterdam.nl,
>> Rene
>
>
> --
> 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] foreach weirdness

2012-03-25 Thread Simon Schick
2012/3/25 Arno Kuhl :
>
> will not only give the wrong result, it will corrupt the array for *any* 
> further use of that array. I still think it’s a bug according to the 
> definition of foreach in the php manual. Maybe php needs to do an implicit 
> unset at the closing brace of the foreach where was an assign $value by 
> reference, to remove the reference to the last element (or whatever element 
> it was pointing to if there was a break) so that it doesn't corrupt the 
> array, because any assign to $value after the foreach loop is completed will 
> corrupt the array (confirmed by testing). The average user (like me) wouldn't 
> think twice about reusing $value after ending the foreach loop, not realising 
> that without an unset the array will be corrupted.
>

Hi, Arno

Requesting that will at least require a major-release (f.e. PHP 6.0)
... but I would rather request to add a notice or warning to the
documentation of references to remind stuff like that.
http://www.php.net/manual/en/language.references.php
I think this is stuff more people will stumble over ...

Bye
Simon

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



Re: [PHP] foreach weirdness

2012-03-23 Thread Simon Schick
2012/3/23 Robert Cummings 
>
> On 12-03-23 11:16 AM, Arno Kuhl wrote:
>>
>>
>> it still does not produce the correct result:
>> 0 1 3 6 10 15 21
>> 0 1 3 6 10 15 15
>
>
> This looks like a bug... the last row should be the same. What version of
> PHP are you using? Have you checked the online bug reports?
>
>

Hi, Robert

Does not seem like a bug to me ...
http://schlueters.de/blog/archives/141-References-and-foreach.html

What you should do to get the expected result:
Unset the variable after you don't need this reference any longer.

Bye
Simon

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



Re: [PHP] Bug zlib.output_compression not normal work in IIS7.5

2012-03-21 Thread Simon Schick
2012/3/19 小鱼虾 
>
> How I do fix it ?
>
>
> https://bugs.php.net/bug.php?id=61434
>

Hi,

I got a rough overview of the conversation in the bug-tracker ...

You were always talking about a tool you used to test the
gzip-compression ... but why not test it natively?
Using Firefox (with the extension Firebug) or Safari / Chrome for
example you can easily view the respond-header from the server and get
more info out of that.
Just press F12, click on the network-tab, select your request and
search in the response-header for "Content-Encoding: ..."

I would write my own small php-test-script where you just output some
text. Then you're sure that not other code is doing something strange.

Another possible problem: Is the extension zlib enabled at all? The
documentation says that it's disabled by default ...
http://www.php.net/manual/en/zlib.installation.php

Bye
Simon

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



Re: [PHP] Parse errors

2012-03-18 Thread Simon J Welsh
On 19/03/2012, at 6:32 AM, Tim Streater wrote:

> After recently omitting a semicolon from the end of a statement, and having 
> the result be a JavaScript error in an odd place, I'm trying to pin down just 
> what PHP does with such errors. I made a small test script to run at CLI, 
> which does some echoes and then, after that, I miss out a semicolon. On the 
> command line, all I get is the parse error message with line number.
> 
> The script where I'd left the semicolon out of my production code is reached 
> via AJAX, and sends some results back. It consists of a number of functions, 
> then the main code appears, starting with two requires. The first such 
> included file has some functions, puts out a header and does an echo, and 
> calls set_error_handler. It's in the second included file that the semicolon 
> is missed off (inside yet another function).
> 
> I would have expected that the results sent back would just consist of the 
> Parse error: message, but for some reason the echo done in the first included 
> file shows up as well (this is important as it frames the parse error message 
> for me).
> 
> Is this the expected behaviour? The doc for set_error_handler says you can't 
> use it to recover from E_PARSE and the like, and the function I supply to it 
> doesn't appear to be called. I was just surprised that the initial echo 
> statement's output made it back to the JavaScript side.
> 
> (I obviously don't expect to have parse errors show up in production, but 
> having them nicely visible and logged during testing is useful)
> 
> --
> Cheers  --  Tim

This is expected. The error doesn't occur to the second file is included, so 
everything in the first included file is parsed and run before execution is 
halted.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Have little enough hair as it is ...

2012-03-12 Thread Simon Schick
2012/3/12 Lester Caine :
> More irritating is
> 'Notice: Array to string conversion' which are coming up all over the place.
> I can understand what the problem is ... but trying to remove the notices is
> more challenging ...
>
> $secondsGap[] = array($gap[0] * 60, $gap[1] * 60);
> if( isset($secondsGap[1]) ) {
>        $gapName = $secondsGap[0]."to".$secondsGap[1];
> } else {
>        $gapName = $secondsGap[0];
> }
> $secondsGap[] is two numbers, which are used to create the name string, so
> what is the 'official' way of making this work without generating warnings?
>

Hi, Lester

I suggest that all done with this variable before is not of interest ...
Assuming this, I'd say the following:

> $secondsGap[] = array($gap[0] * 60, $gap[1] * 60);
Implicit initializing of an array that has the following structure:
array( array(int, int) );

> if( isset($secondsGap[1]) ) {
Trying to get the second element .. which will never happen if you
haven't added an element before the snipped you pasted here.

>$gapName = $secondsGap[0]."to".$secondsGap[1];
> } else {
>$gapName = $secondsGap[0];
> }
[some-code]

I'm quite unsure what you want to do here. If you'd update the first
line as following it would always trigger the first condition:
$secondsGap = array($gap[0] * 60, $gap[1] * 60);

Bye
Simon

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



Re: [PHP] Have little enough hair as it is ...

2012-03-11 Thread Simon Schick
2012/3/11 Lester Caine :
> ( Been down London over night ;) ) ... and was not awake enough to change
> email address ...
>
>
>> http://piwik.medw.org.uk/phpinfo.php has http://piwik.medw.org.uk/ working
>> fine...
>>
>> http://piwik.rainbowdigitalmedia.org.uk/phpinfo.php is just giving seg
>> faults on http://piwik.rainbowdigitalmedia.org.uk/ but
>> http://rainbowdigitalmedia.org.uk/ is working perfectly.
>>
>> The piwik analytics is based on Zend, and I've not been able to get it
>> working on either of the two new machines, while all of my other stuff is
>> working fine. I started with Apache2.4.1 and PHP5.4.0 and moved back to
>> what
>> should be the same versions as the working machines but without success.
>
>
> Simon Schick wrote:
>>
>> Can you give us some more information?
>
> I've been working on this for some days and tried various combinations of
> Apache and PHP, but my starting point was Ap2.4.1 with PHP5.4.0 and I've now
> worked my way back through versions to what should be the same as setup as
> is working on piwik.medw.org.uk but I have yet to get piwik to run on either
> new machine!
>
>> How is php called in your apache-configuration? (f)cgi, module or somehow
>> else?
>> You said that the configuration should be the same ... can you
>> double-check that? Reload the services etc ...
>
> Always used module and I see no reason to change
> I've enabled and disable just about everything, and the installer tells me
> the set-up is fine.
>
>> What about the logs? There must be more info in there ...
>
> THAT is what is pissing me off. ZEND does not seem to log anything usable
> and I have yet to establish the best way of debugging it. The rest of my
> stuff simply worked, gave the expected new nagging and allowed me to track
> and tidy them. EVERY configuration of ZEND based piwik just gives ...
> [notice] child pid 10345 exit signal Segmentation fault (11)
> With eaccelerator switched on and tracking, I can see files being cached,
> but have yet to work out what the next file would be, and to be honest, I'm
> not convinced it runs the same way every time, but that is probably just the
> order of parallel paths being run?
>
> --
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Hi, Lester

You're talking about some kind of "installer" ... What exactly is it?
And what exactly do you mean with "ZEND does not seem to log ..."?
Apache, PHP or something that's controlling both?
And the more interesting question as you're only talking about ZEND
... in which log-file have you found the notice? I guess it's the
log-file of Apache ...
I guess you have already tried to set Apache and PHP to the lowest
possible error-level ...

I searched up the inet and came across totally different solutions ...

Things that I found you can try:
* Replace the index.php ... Some people reported that this error was
caused by an endless-loop in their php-script
* Disable all php-modules that are not really needed (f.e. APC or eAccelerator)
* Disable all superfluous apache-modules (you should have done that
anyways, but let's try to put it to a minimum)

Here's also one tutorial how to get more information out of the
apache-process. Haven't tried that and can therefore just give the
hint to test it once.
http://stackoverflow.com/questions/7745578/notice-child-pid-3580-exit-signal-segmentation-fault-11-in-apache-error-l

Hope you can get some more details ...

Bye
Simon

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



Re: [PHP] Have little enough hair as it is ...

2012-03-10 Thread Simon Schick
Hi, Lester

Can you give us some more information?

How is php called in your apache-configuration? (f)cgi, module or somehow else?
You said that the configuration should be the same ... can you
double-check that? Reload the services etc ...

What about the logs? There must be more info in there ...

Bye
Simon

2012/3/10 Lester Caine :
> OK this has got to be some configuration problem!
> I've two machines running fine Apache 2.2.15/PHP5.3.8 and two not with what
> should be identical Apache/PHP setups.
> All SUSE machines but 11.3, 11.4 and 12.1 with 11.3 and 11.4 machine running
> fine ...
>
> http://piwik.medw.org.uk/phpinfo.php has http://piwik.medw.org.uk/ working
> fine...
>
> http://piwik.rainbowdigitalmedia.org.uk/phpinfo.php is just giving seg
> faults on http://piwik.rainbowdigitalmedia.org.uk/ but
> http://rainbowdigitalmedia.org.uk/ is working perfectly.
>
> The piwik analytics is based on Zend, and I've not been able to get it
> working on either of the two new machines, while all of my other stuff is
> working fine. I started with Apache2.4.1 and PHP5.4.0 and moved back to what
> should be the same versions as the working machines but without success.
>
> ANYBODY got any ideas?
> What should I be doing next to try and track down where the seg fault is
> coming from?
>
> --
> Lester Caine - G8HFL
> -
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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



Re: [PHP] file url access funniness

2012-03-10 Thread Simon Schick
Hi, TR Shaw

I would next try curl as php-extension.
If that is working well, and you need it definitely with file() I'd use
Wireshark to check which request is sent to the remote machine.

Bye
Simon

2012/3/10 TR Shaw 

> This is weird.  This statement fails:
>
>$tlds = file("http://www.surbl.org/tld/three-level-tlds";,
> FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
>
> Warning: file(http://www.surbl.org/tld/three-level-tlds): failed to open
> stream: HTTP request failed! HTTP/1.0 502 Bad Gateway
>
> also tried the final location and it fails with:
>
> Warning: file(http://george.surbl.org/two-level-tlds): failed to open
> stream: HTTP request failed!
>
> But a browser and the following work:
>
>$response = shell_exec("curl -s -S -L
> http://data.iana.org/TLD/tlds-alpha-by-domain.txt -o
> tlds-alpha-by-domain.txt");
>
> Any ideas?  I'd rather not use curl if possible.
>
> TIA,
>
> Tom
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Function mktime() documentation question

2012-03-07 Thread Simon Schick
Hi, All

To bring a work-around into this discussion I myself would not see it
as a good way to do it like that - even if the documentation provides
some information around that.
Here's what I have done in all new projects I worked with time-calculation:

@Tedd: Lets pick up your first example and work with the
DateTime-Object instead:

$date = new DateTime($year . '-' . $current_month . '-1');
$date->add( new DateInterval( 'P1M' ) ); // Add a period of 1 month to
the date-instance (haven't tried that with the 30th of Jan ... would
be kind-of interesting)

$days_in_current_month = $date->format('j'); // Get the date of the month

As this does not solve the problem (as we still should update the
documentation or the code if it does not match) it's not a solution,
but a suggestion to coding-style at all.
It seems a bit cleaner to me as you don't have to worry about the 13th
month, time-zones or other things that can be difficult to calculate
yourself.

Bye
Simon

2012/3/8 shiplu :
>> To get the number of days for a specific month, I use:
>>
>> // $current_month is the month under question
>>
>> $next_month = $current_month + 1;
>
> I use this
>
> $next_month = $current_month + 1;
> $next_month_1    = mktime(0, 0, 0,     $next_month, 1, date("Y") );
> $current_month_1= mktime(0, 0, 0, $current_month, 1, date("Y") );
> $mdays = ($current_month_1 - $next_month_1)/(3600*24);
>
> It's much more easier if you use DateTime and DateInterval class
>
>
>
> --
> Shiplu.Mokadd.im
> ImgSign.com | A dynamic signature machine
> Innovation distinguishes between follower and leader

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



Re: [PHP] SESSION var and Objects problem

2012-03-02 Thread Simon Schick
Hi, Jim

To avoid this kind of problem it would also help to provide an
autoloader-function as PHP then tries to load the class-definition by this
autoloader ;)
Using that you'd bind yourself to have a pretty good system for php-classes
and you'd avoid having problems like that.

I'd in fact have never thought about a solution like that - but that may
comes from the fact that I always use auto-loader-scripts ;)

One additional info:
I had some problems putting an instance of *SimpleXmlElement *into the
session ... The only valuable info I found was this error:
*Fatal error: Exception thrown without a stack frame in Unknown on line 0*

Here's the solution and description why:
http://stackoverflow.com/questions/4624223/object-in-session-fatal-error-exception-thrown-without-a-stack-frame-in-unknow#answer-4624256

Bye
Simon

2012/3/2 Jim Giner 

> "Stuart Dallas"  wrote in message
> news:7eeba658-c7f6-4449-87bd-aac71b41e...@3ft9.com...
>
> Make sure the class is declared before you call session_start.
> *
>
> You Da Man!!
>
> I see now why it makes a difference.  The session tries to bring back the
> data but doesn't know how to handle the objects in the session vars since
> the objects haven't been defined.  Never would of thought of that!
>
> Thank you for being there!  :)
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Website preview script

2012-02-29 Thread Simon Schick
Hi, Ashley

The question is what this function does ;)
I think it really takes a screenshot of the server - whatever is shown
there right now. But how to get a browser running there in full-screen?

I came around that post for a couple of weeks ago and thought it could be
useful for someone here:
http://www.phpgangsta.de/screenshots-von-webseiten-erstellen-mit-php

Bye
Simon

2012/2/29 Ashley Sheridan 

> **
> On Wed, 2012-02-29 at 19:54 +0100, Simon Schick wrote:
>
>
> Hi, Nibin
>
> I wonder what you'd call a  ...
> Do you mean a screenshot or the HTML-response from the server, specially
> prepared (sounds like you want to create a proxy ;))?
>
> Bye
> Simon
>
> 2012/2/29 Nibin V M 
>
> > No..what I am trying to write a "website preview" plugin attached to a
> > control panel.. :)
> >
> > since I am a newbie, I don't know how to achieve this without modifying
> > hosts file ( I am basically a linux sys admin ) :)
> >
> > @Martin -  I will check it. Since I am a beginner ( of course, just started
> > to learn PHP today ) I need to start from scratch. If yo could provide some
> > sample code, it will be great :)
> >
> > thanks for your input guys..
> >
> > On Thu, Mar 1, 2012 at 12:11 AM, Ashley Sheridan
> > wrote:
> >
> > > **
> > > On Wed, 2012-02-29 at 19:29 +0100, Matijn Woudt wrote:
> > >
> > > On Wed, Feb 29, 2012 at 7:07 PM, Nibin V M  wrote:
> > > > Hello,
> > > >
> > > > I am very new to PHP coding. I am trying to achieve a task via PHP,
> > > > regarding which I have been googling around for a few days and now
> > come up
> > > > with emtpy hands!
> > > >
> > > > Ok, what I need to write is a "website preview script". That is I need
> > to
> > > > display a website hosted on serverA and pointing elsewhere, from
> > ServerA (
> > > > via curl possibly ).
> > > >
> > > > For example: I have configured techsware.in and google.com on ServerA
> > ( of
> > > > course google.com pointing to their IP ). I need to display the
> > contents of
> > > > google.com "on my server" , if I call 
> > > > http://techsware.in/google.phpwhich
> > > > has some curl coding in it! Note, what I have is the domain name (
> > > > google.com ) and the IP on which it is hosted on serverA to achieve
> > this.
> > > > Any way to achieve this?
> > > >
> > > > I can achieve this if I put  google.com
>  in /etc/hosts file (
> > its
> > > > Linux ). But I need to run this script for normal users as well, which
> > > > won't have super user privileges and thus unable to edit /etc/hosts
> > file.
> > > > So I want to specify somewhere in the PHP script that, google.compoints 
> > > > to
> > > > . I can do this with this little script.
> > > >
> > >
> > > How about just doing a str_replace[1]?
> > >
> > > - Matijn
> > >
> > > [1]http://www.php.net/str_replace
>
> > >
> > >
> > > Why can't you use an iframe, or are you trying to offer this other
> > > websites content as if it were on your own site? If so, I would first
> > check
> > > to see if you're actually allowed to do that, as that will bring up
> > quite a
> > > few copyright issues otherwise, which can be very expensive.
> > >
> > >   --
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > >
> > >
> >
> >
> > --
> > Regards
> >
> > Nibin.
> >
> > http://TechsWare.in
> >
>
>
> It does sound more like a proxy than a preview script.
>
> What about using something like this:
> http://uk3.php.net/manual/en/function.imagegrabscreen.php
>
> I've never used it, but on first appearances it looks like it should
> produce the preview you require.
>
>
>   --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


Re: [PHP] Website preview script

2012-02-29 Thread Simon Schick
Hi, Nibin

I wonder what you'd call a  ...
Do you mean a screenshot or the HTML-response from the server, specially
prepared (sounds like you want to create a proxy ;))?

Bye
Simon

2012/2/29 Nibin V M 

> No..what I am trying to write a "website preview" plugin attached to a
> control panel.. :)
>
> since I am a newbie, I don't know how to achieve this without modifying
> hosts file ( I am basically a linux sys admin ) :)
>
> @Martin -  I will check it. Since I am a beginner ( of course, just started
> to learn PHP today ) I need to start from scratch. If yo could provide some
> sample code, it will be great :)
>
> thanks for your input guys..
>
> On Thu, Mar 1, 2012 at 12:11 AM, Ashley Sheridan
> wrote:
>
> > **
> > On Wed, 2012-02-29 at 19:29 +0100, Matijn Woudt wrote:
> >
> > On Wed, Feb 29, 2012 at 7:07 PM, Nibin V M  wrote:
> > > Hello,
> > >
> > > I am very new to PHP coding. I am trying to achieve a task via PHP,
> > > regarding which I have been googling around for a few days and now
> come up
> > > with emtpy hands!
> > >
> > > Ok, what I need to write is a "website preview script". That is I need
> to
> > > display a website hosted on serverA and pointing elsewhere, from
> ServerA (
> > > via curl possibly ).
> > >
> > > For example: I have configured techsware.in and google.com on ServerA
> ( of
> > > course google.com pointing to their IP ). I need to display the
> contents of
> > > google.com "on my server" , if I call http://techsware.in/google.phpwhich
> > > has some curl coding in it! Note, what I have is the domain name (
> > > google.com ) and the IP on which it is hosted on serverA to achieve
> this.
> > > Any way to achieve this?
> > >
> > > I can achieve this if I put  google.com in /etc/hosts file (
> its
> > > Linux ). But I need to run this script for normal users as well, which
> > > won't have super user privileges and thus unable to edit /etc/hosts
> file.
> > > So I want to specify somewhere in the PHP script that, google.compoints to
> > > . I can do this with this little script.
> > >
> >
> > How about just doing a str_replace[1]?
> >
> > - Matijn
> >
> > [1]http://www.php.net/str_replace
> >
> >
> > Why can't you use an iframe, or are you trying to offer this other
> > websites content as if it were on your own site? If so, I would first
> check
> > to see if you're actually allowed to do that, as that will bring up
> quite a
> > few copyright issues otherwise, which can be very expensive.
> >
> >   --
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>
>
> --
> Regards
>
> Nibin.
>
> http://TechsWare.in
>


Re: [PHP] How do I enable more useful PHP error logging?

2012-02-29 Thread Simon Schick
Hi, Daevid

What you could do to have it quick is to install the plugin xdebug.

Here you can (as described in the documentation linked here) enable to get
some extra information for a E_* message from php.
http://xdebug.org/docs/stack_trace

I would not do that on a live-system where you have 30k v/s without
changing the default configuration as there are several options that would
dramatically slow down the system.
But if you're configuring this properly I think you'll get the best
information without changing the php-code itself.

Bye
Simon

2012/2/29 Tommy Pham 

> On Tue, Feb 28, 2012 at 3:14 PM, Daevid Vincent  wrote:
> > My question is, is there a way to enable some PHP configuration that
> would
> > output more verbose information, such as a backtrace or the URL
> attempted?
> >
>
> Have you looked at log4php? [1] It's a log4j (Java based) logging
> facility port to PHP.  IIRC for log4j, you can do various logging from
> FINEST, FINER, FINE, INFO, WARNING, ERROR (?), SEVERE levels within
> the application.  You can adjust levels as needed at run time.  You
> may want to have a wrapper that will do back trace and record the
> requested URL.  The log4* facility does rolling file logging, DB,
> e-mail, syslog, etc.  (I've used the log4j and log4net before.)  Very
> handy and flexible, IMO.
>
> HTH,
> Tommy
>
>
> [1] http://logging.apache.org/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] SimpleXML and the Single String (SOLVED)

2012-02-21 Thread Simon Schick
Hi, Jay

If you're not using the variable *$xmlCompany* somewhere else I'd try to
skip the array and just do it with this single line:
*$arrayLead[0]->Company = (string)
$xml->SignonRq->SignonTransport->CustId->SPName;*

The result should not differ from what you have now.

Bye
Simon

2012/2/21 Jay Blanchard 

> Howdy,
>
> My PHP chops are a little rough around the edges so I know that I am
> missing something. I am working with SimpleXML to retrieve values from an
> XML file like this -
>
> $xmlCompany = $xml->SignonRq->SignonTransport->CustId->SPName;
>
> If I echo $xmlCompany I get the proper information.
>
> If I use $xmlCompany as an array value though, I get this object -
>
> $arrayLead[0]->Company = $xmlCompany; // what I did
> [Company] => SimpleXMLElement Object // what I got
>(
>[0] => Dadgummit
>)
> I tried casting AND THEN AS I TYPED THIS I figured it out...
>
> $xmlCompany = array((string)
> $xml->SignonRq->SignonTransport->CustId->SPName); // becomes an array
> $arrayLead[0]->Company = $xmlCompany[0]; // gets the right bit of the array
>
> and the result is
>
>  [Company] => Dadgummit
> Thanks for bearing with me!
>
>
>
>
>


Re: [PHP] basic captcha

2012-02-17 Thread Simon Schick
Hei, Ashley

The php bugtracker himself uses just simple math.
Others are made by clicking on the man's name in the picture (3 shaddows of
people with names in there) ...

But I myself dislike the visitor having extra-work. Therefore I'll stick to
the honey-pot the referer check and so on.
One check I think is quite effective is something google does for
discovering spam-mail:
Discover which language this mail is written in. If it does not seem to be
a lanuage at all its most likely spam ;) But I think that's not possible
for not-so-big websites ..

Anyways: most likely it's just about filtering the 99% spam and get all
user-mails through. Nothing is more annoying as when you (as user) get the
feedback "*Go away! You're a bot.*" ;)

Bye
Simon

2012/2/17 Ashley Sheridan 

>
>
> Simon Schick  wrote:
>
> >Hi, all
> >
> >When you ask for a captcha, I'd first ask what do you want to use it
> >for.
> >If you read the first lines of Wikipedia it has been developed to
> >differ
> >between a real user and a bot.
> >
> >If you'd now say that you want to use it to protect spam in a formula
> >I'd
> >give you the same explanation that you can find here in german (in a
> >bit
> >more text): http://www.1ngo.de/web/captcha-spam.html
> >The author of this link says that captchas are not efficient enough and
> >give a new unnecessary barrier to all users. He also declaims that bots
> >nowadays are better than ever and can even read captchas that many
> >humans
> >are not able to read.
> >For this reason he provides a list of extra stuff that you can use to
> >protect your formula against spam instead of a picture that's text
> >should
> >be written in an input-field.
> >
> >One of those is the honey-pot. You simply create an additional field
> >(f.e. *
> >email2*) hide it for most visitors (using *css*) and ignore the comment
> >if
> >there's text in here. As most of the bots cannot read css they'll fill
> >a
> >valid email-address in here :) But then you also have to think about
> >users
> >that have css disabled f.e. *ScreenReader*. Another disadvantage of
> >this
> >issue is that you can use an auto-field-fill mechanism provided by the
> >browser who could fill this field ... But both cases should not be that
> >difficult. For the screenreder you can change the label for the field
> >to
> >look like *Do not paste your email in here. Just leave it empty.* Just
> >to
> >have the word email again in here ;)
> >
> >Another good thing is to think about how fast this form can be
> >submitted
> >when the user enters the formula for the first time. Also think about
> >the
> >second time, when the user as entered some wrong values and you have to
> >show him a message.
> >If you have a formula that contains more than 5 fields it's quite
> >unusual
> >that the user can submit that below 2 sec after receiving the response.
> >You
> >could even add a feature by using javascript that the user cannot
> >submit
> >this form or his request will be delayed for a view seconds (one or
> >two).
> >
> >If you want to know more about that, out there are plenty of plugins
> >for
> >different systems where you can see what other possibilities you have.
> >One
> >extension i like is the one from TYPO3. They have quite a bunch of such
> >things and you can give each of the checks a value. If the sum of the
> >values of the failing tests reaches a configured level, this
> >form-submission will be rejected.
> >http://typo3.org/extensions/repository/view/wt_spamshield/current/
> >
> >Wordpress: http://antispambee.de/
> >
> >Bye
> >Simon
> >
> >2012/2/17 Savetheinternet 
> >
> >> On Fri, Feb 17, 2012 at 3:40 PM, Donovan Brooke 
> >wrote:
> >> > Hello,
> >> >
> >> > Does anyone know of a basic (open source or freeware) form captcha
> >system
> >> > for PHP?
> >> >
> >> > TIA,
> >> > Donovan
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > D Brooke
> >> >
> >>
> >> Hi,
> >>
> >> There are plenty of free PHP captcha scripts out there. Just google
> >> "captcha PHP". Securimage (phpcaptcha.org) looks relatively okay.
> >>
> >> Thanks,
> >> Michael
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
>
> I would avoid making a user type in something they see in a picture, as
> you've just succeeded in pissing off a bunch of blind people.
>
> Also, avoid relying on javascript. It can be turned off, disabled, blocked
> and sometimes isn't available at all, such as with some speech/Braille
> browsers.
>
> One popular route is to ask a question that only a human could answer. I
> use this method on the contact page of my site. I just ask a question such
> as
>
> Multiply the number of heads a person has by the number of legs on 2 dogs.
>
> It's easy for a human, but requires context, something a bot can't do
> effectively.
> Thanks,
> Ash
> http://ashleysheridan.co.uk
>


Re: [PHP] pathinfo or other

2012-02-17 Thread Simon Schick
Hi,

Just to also add the discussion why mod_rewrite or PATH_INFO :)
http://stackoverflow.com/questions/1565292/mod-rewrite-or-path-info-for-clean-urls

Bye
Simon

2012/2/17 Simon Schick 

> Hi, All
>
> I do not remember where I found the list of variables that are provided if
> you load PHP using Apache, nginx, IIS ...
> Fact is that there's a list of variables in the CGI 1.1 definition that
> should be given to a cgi script:
> http://tools.ietf.org/html/rfc3875#section-4
> PATH_INFO is on the list and therewith should at least be given to every
> cgi-script.
>
> As not all web-server are fully compatible to the definition or do not
> support cgi 1.1 there are quite much posts where you find work-arounds for
> misconfiguration web-servers.
> I know about nginx that you have to add a special configuration to get the
> path_info - but the example provided at the developers-page sometimes
> returns a wrong value. See:
> http://stackoverflow.com/questions/8265941/empty-value-to-path-info-in-nginx-returns-junk-value/
>
> Maybe there are also some other known issues around this PATH_INFO ...
> Here's a request for a portable way to receive the path-info even if it's
> not provided by the web-server:
> http://stackoverflow.com/questions/1884041/portable-and-safe-way-to-get-path-info
>
> I've always tried to use something like mod_rewrite and manage all
> incoming requests in an own dispatcher. That helped me a lot getting around
> this problems.
>
> Hope that this gives you more detailed information in what you need.
>
> Bye
> Simon
>
>
> 2012/2/17 Donovan Brooke 
>
>> Elbert F wrote:
>>
>>> SCRIPT_NAME is a server side path, try REQUEST_URI. This includes the
>>> query
>>> string but it's easy to remove.
>>>
>>> Elbert
>>> http://swiftlet.org
>>>
>>
>>
>> Hi, I thought I should say that server side SCRIPT_NAME seems to be fine
>> for me in this case. Thanks for the input.
>>
>>
>> Donovan
>>
>>
>>
>>
>> --
>> D Brooke
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>


Re: [PHP] pathinfo or other

2012-02-17 Thread Simon Schick
Hi, All

I do not remember where I found the list of variables that are provided if
you load PHP using Apache, nginx, IIS ...
Fact is that there's a list of variables in the CGI 1.1 definition that
should be given to a cgi script:
http://tools.ietf.org/html/rfc3875#section-4
PATH_INFO is on the list and therewith should at least be given to every
cgi-script.

As not all web-server are fully compatible to the definition or do not
support cgi 1.1 there are quite much posts where you find work-arounds for
misconfiguration web-servers.
I know about nginx that you have to add a special configuration to get the
path_info - but the example provided at the developers-page sometimes
returns a wrong value. See:
http://stackoverflow.com/questions/8265941/empty-value-to-path-info-in-nginx-returns-junk-value/

Maybe there are also some other known issues around this PATH_INFO ...
Here's a request for a portable way to receive the path-info even if it's
not provided by the web-server:
http://stackoverflow.com/questions/1884041/portable-and-safe-way-to-get-path-info

I've always tried to use something like mod_rewrite and manage all incoming
requests in an own dispatcher. That helped me a lot getting around this
problems.

Hope that this gives you more detailed information in what you need.

Bye
Simon

2012/2/17 Donovan Brooke 

> Elbert F wrote:
>
>> SCRIPT_NAME is a server side path, try REQUEST_URI. This includes the
>> query
>> string but it's easy to remove.
>>
>> Elbert
>> http://swiftlet.org
>>
>
>
> Hi, I thought I should say that server side SCRIPT_NAME seems to be fine
> for me in this case. Thanks for the input.
>
>
> Donovan
>
>
>
>
> --
> D Brooke
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] basic captcha

2012-02-16 Thread Simon Schick
Hi, all

When you ask for a captcha, I'd first ask what do you want to use it for.
If you read the first lines of Wikipedia it has been developed to differ
between a real user and a bot.

If you'd now say that you want to use it to protect spam in a formula I'd
give you the same explanation that you can find here in german (in a bit
more text): http://www.1ngo.de/web/captcha-spam.html
The author of this link says that captchas are not efficient enough and
give a new unnecessary barrier to all users. He also declaims that bots
nowadays are better than ever and can even read captchas that many humans
are not able to read.
For this reason he provides a list of extra stuff that you can use to
protect your formula against spam instead of a picture that's text should
be written in an input-field.

One of those is the honey-pot. You simply create an additional field (f.e. *
email2*) hide it for most visitors (using *css*) and ignore the comment if
there's text in here. As most of the bots cannot read css they'll fill a
valid email-address in here :) But then you also have to think about users
that have css disabled f.e. *ScreenReader*. Another disadvantage of this
issue is that you can use an auto-field-fill mechanism provided by the
browser who could fill this field ... But both cases should not be that
difficult. For the screenreder you can change the label for the field to
look like *Do not paste your email in here. Just leave it empty.* Just to
have the word email again in here ;)

Another good thing is to think about how fast this form can be submitted
when the user enters the formula for the first time. Also think about the
second time, when the user as entered some wrong values and you have to
show him a message.
If you have a formula that contains more than 5 fields it's quite unusual
that the user can submit that below 2 sec after receiving the response. You
could even add a feature by using javascript that the user cannot submit
this form or his request will be delayed for a view seconds (one or two).

If you want to know more about that, out there are plenty of plugins for
different systems where you can see what other possibilities you have. One
extension i like is the one from TYPO3. They have quite a bunch of such
things and you can give each of the checks a value. If the sum of the
values of the failing tests reaches a configured level, this
form-submission will be rejected.
http://typo3.org/extensions/repository/view/wt_spamshield/current/

Wordpress: http://antispambee.de/

Bye
Simon

2012/2/17 Savetheinternet 

> On Fri, Feb 17, 2012 at 3:40 PM, Donovan Brooke  wrote:
> > Hello,
> >
> > Does anyone know of a basic (open source or freeware) form captcha system
> > for PHP?
> >
> > TIA,
> > Donovan
> >
> >
> >
> >
> > --
> > D Brooke
> >
>
> Hi,
>
> There are plenty of free PHP captcha scripts out there. Just google
> "captcha PHP". Securimage (phpcaptcha.org) looks relatively okay.
>
> Thanks,
> Michael
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Swiftlet is quite possibly the smallest MVC framework you'll ever use.

2012-02-13 Thread Simon Schick
Hi, Elbert

I personally would remove the set_error_handler completely. This is a
configuration that the administrator has to handle himself. In a
development-env they want to see all errors, warnings etc, yes - even a
strict_notice. But in a production-env they dont want to show anything to
the user - just show a general error if something really heavy happened.
You can put that in the index.php but I'd wrap it in comments or remove it.

In my opinion it's a good idea to move the autoloader into the index.php.
Then you can even call your app class using the autoloader ;)

I'm just curious what exactly you want to try with the plugins ... Should
they simply be extensions or also possibilities to extend other plugins? I
also wrote my own framework 3 years ago and was more about making things
way more complex than they could be just to think about maximum flexibility
..

I pretty much also like the no-config part.
http://en.wikipedia.org/wiki/Convention_over_configuration


Bye
Simon

2012/2/12 Elbert F 

> Hi Simon,
>
> I think you're right that I may be abusing the constructor a bit. I'm
> going to follow your suggestion and split it up into smaller functions. I'm
> also thinking of moving the set_error_handler and spl_autoload_register
> functions to index.php where Swiftlet is bootstrapped so they can be
> changed.
>
> You make another good point about the model; it's never supposed to access
> the controller or view. I updated the code to reflect this. It should work
> like your second 
> flowchart<http://betterexplained.com/wp-content/uploads/rails/mvc-rails.png>(perhaps
>  with the added concept of plugins, which can hook into anything).
>
> Symfony's routing is nice, many smaller frameworks take a similar approach
> (e.g. Sinatra <http://www.sinatrarb.com/> and ToroPHP<http://toroweb.org/>).
> However, I like the fact that Swiftlet requires no configuration. Just drop
> in your class and it works. The file structure and classes already do a
> good job describing themselves.
>
> Excellent feedback, thanks!
>
> Elbert
>
>
>
> On Sun, Feb 12, 2012 at 10:53 PM, Simon Schick <
> simonsimc...@googlemail.com> wrote:
>
>> Hi, Elbert
>>
>> I've looked through the code and found it quite tiny :) I like that.
>>
>> Until now I found some things that I'd like to discuss with you:
>>
>> In the class App you're doing all the stuff (routing, calling the
>> constructor aso) in the constructor. Would it not be better to have
>> separate functions for that? I like the way I learned from using Java: The
>> constructor is only for initializing the variables you need to execute the
>> other functions of this class.
>> Of course you can have a function that then calls all those small
>> functions and maybe directly return the output.
>>
>> I dislike the way you treat with the model .. currently it gets the
>> controller, the view and the app itself. If you ask me the model only needs
>> some configuration. I cannot come up with an idea where you'd need more
>> than a connection-string and some additional settings. The model has
>> several methods to gather the data that has been requested and gives it
>> back. If you'd ask me, there's no need for interaction with the app,
>> controller or view.
>>
>> I'd like to see an option for the router like the one I've seen in
>> symfony2 ... that was quite nice .. There you can define a regexp that
>> should match the called url, some variables that should be extracted from
>> that and some default-variables. It's quite hard to explain in the short
>> term, but take a look at their documentation:
>> http://symfony.com/doc/current/book/routing.html
>>
>> I'd like you to create a small workflow what your framework is doing in
>> which order. Your framework to me looks like this image:
>> http://imageshack.us/f/52/mvcoriginal.png/ But I'd rethink if this
>> structure would give you more flexibility:
>> http://betterexplained.com/wp-content/uploads/rails/mvc-rails.png
>>
>> I hope you got some input here you can work with. I'd like to hear your
>> feedback.
>>
>> Bye
>> Simon
>>
>>
>> 2012/2/12 Elbert F 
>>
>>> I'm looking for constructive feedback on Swiftlet, a tiny MVC framework
>>> that leverages the OO capabilities of PHP 5.3. It's intentionally
>>> featureless and should familiar to those experienced with MVC. Any
>>> comments
>>> on architecture, code and documentation quality are very welcome.
>>>
>>> Source code and documentation: http://swiftlet.org
>>>
>>
>>
>


Re: [PHP] Swiftlet is quite possibly the smallest MVC framework you'll ever use.

2012-02-13 Thread Simon Schick
Hi, Paul

I personally pretty much like the idea of auto-loaders, but that's a
personal point of view.
If you have always develop with scripts having autoloaders you'll hate to
write a *require_once* command at the beginning of all files. And what
would a dependency-injection-container be without an autoloader ;)
http://www.slideshare.net/fabpot/dependency-injection-with-php-53

If you write your code in OOP you should always have unique class-names. If
you follow this and use a good naming-convention both ways should be
usable. I prefer to use autoloaders, you maybe not and that makes code so
personalized ;) *like-it*

Bye
Simon

2012/2/13 Benjamin Hawkes-Lewis 

> On Sun, Feb 12, 2012 at 11:36 PM, Paul M Foster 
> wrote:
> > The more I've thought about it since then, the more I've considered it a
> > Good Thing(tm). It makes troubleshooting existing code a whole lot
> > easier. I don't have to wonder what the autoloader is doing or where the
> > files are, on which the current file depends. It sort of obviates the
> > autoloader stuff, but I'd rather do that than spend hours trying to
> > track down which file in which directory contains the class which paints
> > the screen blue or whatever.
>
> Yeah, this is the sort of problem better handled by a tool than
> switching away from autoloaders.
>
> Exuberant Ctags is your friend.
>
> --
> Benjamin Hawkes-Lewis
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Swiftlet is quite possibly the smallest MVC framework you'll ever use.

2012-02-12 Thread Simon Schick
Hi, Elbert

I've looked through the code and found it quite tiny. I like that.

Until now I found some things that I'd like to discuss with you:

In the class App you're doing all the stuff (routing, calling the
constructor aso) in the constructor. Would it not be better to have
separate functions for that? I like the way I learned from using Java: The
constructor is only for initializing the variables you need to execute the
other functions of this class.
Of course you can have a function that then calls all those small functions
and maybe directly return the output.

I dislike the way you treat with the model .. currently it gets the
controller, the view and the app itself. If you ask me the model only needs
some configuration. I cannot come up with an idea where you'd need more
than a connection-string and some additional settings. The model has
several methods to gather the data that has been requested and gives it
back. If you'd ask me, there's no need for interaction with the app,
controller or view.

I'd like to see an option for the router like the one I've seen in symfony2
... that was quite nice .. There you can define a regexp that should match
the called url, some variables that should be extracted from that and some
default-variables. It's quite hard to explain in the short term, but take a
look at their documentation:
http://symfony.com/doc/current/book/routing.html

I'd like you to create a small workflow what your framework is doing in
which order. Your framework to me looks like this image:
http://imageshack.us/f/52/mvcoriginal.png/ But I'd rethink if this
structure would give you more flexibility:
http://betterexplained.com/wp-content/uploads/rails/mvc-rails.png

I hope you got some input here you can work with. I'd like to hear your
feedback.

Bye
Simon


2012/2/12 Elbert F 

> I'm looking for constructive feedback on Swiftlet, a tiny MVC framework
> that leverages the OO capabilities of PHP 5.3. It's intentionally
> featureless and should familiar to those experienced with MVC. Any comments
> on architecture, code and documentation quality are very welcome.
>
> Source code and documentation: http://swiftlet.org
>


Re: [PHP] Re: Long Live GOTO

2012-02-06 Thread Simon J Welsh

On 7/02/2012, at 9:44 AM, Marco Behnke wrote:

> Am 06.02.12 17:23, schrieb Alain Williams:
>> However: a few GOTOs can make things clearer. Think of a function that
>> can fail in several different places (eg data validation, ...). But it
>> is reading a file which needs to be closed before the function
>> returns. I have seen code where some $IsError variable is tested in
>> many places to see if things should be done. That is just as bad as
>> lots of GOTO -- often when having to write something like that I will
>> have a GOTO (in 
> 
> Good code uses Exceptions and try catch for that kind of scenarios.

Exceptions have a lot of overhead and should only be used in exceptional 
circumstances. I don't see how data validation failing is an exceptional 
circumstance.

I find that using Exceptions and try/catch for something this trivial to be 
more confusing and harder to read (thus worse code) than a goto. It is also 
much easier to make a mistake, especially if you're expecting the catching to 
happen outside of the validation function.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Time zone in date function

2012-01-30 Thread Simon J Welsh
On 31/01/2012, at 2:55 PM, Ron Piggott wrote:

> 
> On my clients account when I use “echo date(‘D, d M Y H:i:s');” the output is 
> 5 hours ahead of us.  How do I change it to my local time?  Is there a way to 
> specify “Eastern” time zone?
> 
> I expect this would work:
> 
> echo date(‘D, d M Y H:i:s' , ( strtotime( date(‘D, d M Y H:i:s') – 21600  ) ) 
> );
> 
> I would prefer to specify Eastern time, so if the web host changes a server 
> setting it will remain in Eastern time zone.  Ron
> 
> 
> Ron Piggott


You can set the timezone for your script using date_default_timezone_set() 
http://php.net/manual/en/function.date-default-timezone-set.php
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Numeric help needed

2012-01-15 Thread Simon J Welsh
On 16/01/2012, at 2:48 PM, Chris Payne wrote:

> Hi Jason,
> 
> I've tried lots of different things, including:
> 
> echo "" . round(68500, 1000) . " ROUNDED";
> 
> thinking that might be it, but i'm stumped
> 
> This is the example I was given (And have to go by):
> 
> "If the loan amount is $68500.00, the insurace will be based on
> $69000.00 as the amount is always rounded up to the next $1000."
> 
> Maybe i'm just looking at it wrong but i'm stumped.
> 
> Chris


The round() function only rounds decimal values. You can use this to emulate 
rounding to a near power of ten by dividing, rounding, then multiplying again. 
i.e. echo "" . round(68500/1000) * 1000 . " ROUNDED";
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Non required argument

2012-01-06 Thread Simon J Welsh
On 7/01/2012, at 2:13 PM, Donovan Brooke wrote:

> Hello,
> 
> I have a simple function that contains an argument that is not required, ie:
> 
> function list_formvars($pmatch) {...
> 
> 
> However, if I call the function without the argument, I get a warning (I'm 
> having the app show all warnings for development):
> 
> "Warning: Missing argument 1 for list_formvars(), called in ..."
> 
> Though the function works fine, how would I go about then making argument not 
> required. I've tried using an if statement with an isset() condition, but 
> perhaps I don't have the syntax correct?
> 
> Anyway,
> TIA for your comments.
> 
> Donovan
> 
> 
> 
> 
> -- 
> D Brooke

function list_formvars($pmatch=null) {...

http://php.net/manual/en/functions.arguments.php#functions.arguments.default

---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Howto detect the hostname of the server?

2011-11-25 Thread Simon J Welsh
On 26/11/2011, at 1:14 PM, Andreas wrote:

> Hi,
> how could I identify the server the script runs on?
> 
> I've got a testserver on Windows and a remote system on Linux that need a 
> couple of different settings like IP and port of db-server or folder to store 
> logfiles.
> 
> I'd like to do something like:
> 
> if ( $_SERVER['some_key'] = 'my_test_box' ) {
>$db_host = '1.1.1.1';
>$db_port = 1234;
> } else {
>$db_host = '2.2.2.2';
>$db_port = 4321;
> }
> 
> 
> I looked into phpinfo() but haven't found anything helpful, yet.
> Have I overlooked something or is there another way to identify the server?


php_uname('n'); http://php.net/php_uname
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] checking dates not working

2011-11-10 Thread Simon J Welsh
On 11/11/2011, at 11:35 AM, Marc Fromm wrote:

> I have this bit of code to see if a date is greater or equal to a set date.
> 
> echo(date("m/d/Y",strtotime($jobs_effective_start)));// displays entered date 
> of 01/03/2012
> echo(date("m/d/Y",strtotime(WSOFFBEGIN))); // displays set date of 09/16/2011
> 
> if (!(date("m/d/Y",strtotime($jobs_effective_start)) >=  
> date("m/d/Y",strtotime(WSOFFBEGIN {
>$error.="The effective start date must be AFTER 
> ".WSOFFBEGIN."\n"; unset($_POST["jobs_effective_start"]);
> }
> 
> My error message is displaying. The if statement is executing as true, as if 
> 01/03/2012 is not greater or equal to 09/16/2011.
> This is not correct since a date in 2012 should be greater than a date in 
> 2011.
> 
> If I use 12/31/2011 as the $job_effective_start date the error message is not 
> displayed since 12/31/2011 is greater than 09/16/2011 and the if statement 
> executes as fasle.
> 
> Any ideas on why a 2012 date is treated as not greater than a 2011 date?
> 
> Thanks
> 
> Marc


String comparisons (which is what is happening here) are done left to right. so 
it's comparing month, then day, then year. You could use a Ymd format or just 
compare the values of strtotime().
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Passing arguments to an internal function via array_map

2011-11-10 Thread Simon J Welsh
On 11/11/2011, at 5:10 AM, Marc Guay wrote:

> Hi folks,
> 
> I'm trying to convert the contents of an array from utf8 to utf16
> (thanks for the headache MS Excel!).  I originally created a "user
> function" that just ran the text through
> mb_convert_encoding($text,'utf-16','utf-8') but now I'm wondering if I
> can't just use the internal function directly.  Apparently it's more
> complicated when the function requires arguments; I see example using
> mysql_real_escape_string() on php.net.
> 
> My current attempt looks like this:
> 
> $clean = array_map('mb_convert_encoding', $dirty_arr, 
> array('utf-16','utf-8'));
> 
> but I believe this is actually passing an array to
> mb_convert_encoding() as the second argument rather than the 2nd and
> 3rd... Any ideas or am I chasing something that can't be done?
> 
> Marc


You need to pass a second and third array to array_map() with the same number 
of elements as the first array. The arguments to the callback function are the 
elements from each array at the same offset.

Something like $clean = array_map('mb_convert_encoding', $dirty_arr, 
array_fill(0, count($dirty_arr), 'utf-16'), array_fill(0, count($dirty_arr), 
'utf-8'));
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] PHP syntax - novice question

2011-10-29 Thread Simon J Welsh
On 30/10/2011, at 1:15 PM, Phil Dobbin wrote:

> Hi, all.
> 
> I’m new to the list & PHP in general & have a syntax question.
> 
> I have a script that calls both DB & MDB2. This is the part of the script 
> where the error occurs:
> 
> 
> 
> if($type == "DB")
>  {
>$db = DB::connect($dsn);
>if (PEAR::isError($db)) { die($db->getMessage()); }
>$db->setFetchMode(DB_FETCHMODE_ASSOC);
>$res = $db->query( 'SELECT * FROM users');
> 
>if (PEAR::isError($res)) {
>  die($res->getMessage());
>}
>echo ‘’;
>while( $res->fetchInto( $row ) ) {
>  print_R($row);
>}
>echo ‘’;
>  } else if($type == "MDB2") {
>$mdb2 =& MDB2::connect($dsn);
>if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); }
> 
>$res = $mdb2->query( 'SELECT * FROM users');
> 
>// Always check that result is not an error
>if (PEAR::isError($res)) {
>  die($res->getMessage());
>}
> 
>echo ‘’;
>while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
>  print_R($row);
>}
>echo ‘’;
>  }
> 
> ###
> 
> The syntax checker calls the first instance ofecho ‘’;   saying 
> unexpected >
> 
> I’m at a loss to understand why...
> 
> I’m using PHP 5.3.8 & PEAR 1.9.4 with MySQL 5.1.59 on Mac OS X 10.6.8.
> 
> Any help appreciated.
> 
> Cheers,
> 
>Phil.

It seems as though your editor has changed the normal quotes around  into 
"pretty" quotes. Change the ‘s and ’s back to '.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] junk from my forms output

2011-10-19 Thread Simon J Welsh

On 20/10/2011, at 10:24 AM, hanson zhou wrote:

> I have the following in a file called "hello.php" in my htdocs directory
> (Apache webroot).
> 
> 
> Your name: 
> Your age: 
> 
> 
> 
> as well as the following in a file "action.php", also in the same directory.
> 
> 
> Hi .
> You are  years old.
> 
> When I click on the submit button of the form in hello.php, it should say
> something like:
> "Hi Hanson.  You are 33 years old."  But instead of just saying that it also
> appends a bunch of junk at the beginning like this:
> 
> {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
> Arial;}} {\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\f0\fs20 Hi
> hanson .\par You are 33 years old.\par } �
> 
> Can someone help me with this?  Why does my forms reply from action.php
> contain so much junk?  I have a Windows installation of PHP and Apache.
> 
> thanks,
> -Hanson


You saved action.php as a RTF file rather than a plain text file. Resave it as 
a plain text file.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] move_uploaded_file() does not return any value or warning

2011-10-14 Thread Simon J Welsh
On 15/10/2011, at 4:01 PM, Partha Chowdhury wrote:

> Then i set a check for the return value of move-uploaded_file.
>> if(isset ($move_uploaded_file)):
>>   echo ""success;
>>   else:
>>   echo "error in uploading";
>>   endif;
> But it does not print anything !

Assuming you did $move_uploaded_file = move_uploaded_file($filename, 
$destination);, then isset($move_uploaded_file) will always be true.

isset() just checks if the variable you past to it is set, not if it has a 
non-false value. You could simply use if(move_uploaded_file($filename, 
$destination)), or if($move_uploaded_file).
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Compile PHP with MySQL support

2011-10-13 Thread Simon J Welsh
On 14/10/2011, at 1:27 AM, Nick Khamis wrote:

> Hello Everyone,
> 
> I am trying to compile php from source using the following config:
> 
> ./configure --prefix=/usr/local/php
> --with-apxs2=/usr/local/apache/bin/apxs
> --with-config-file-path=/usr/local/php
> --with-mcrypt=/usr/local/bin/mcrypt --with-mysqli
> --with-gettext=./ext/gettext --with-pear
> --with-libxml-dir=/usr/include/libxml2 --with-zlib --with-gd
> --enable-pcntl
> 
> Note the mysqli without pointing to /usr/local/mysql/bin/mysql_config.
> The problem is MySQL is not installed on the machine, it is actually
> installed on another server.
> 
> MySQLi Suport:
> 
> mysqli
> MysqlI Support  enabled
> Client API library version  5.1.49
> Active Persistent Links 0
> Inactive Persistent Links   0
> Active Links0
> Client API header version   5.1.49
> MYSQLI_SOCKET   /var/run/mysqld/mysqld.sock
> 
> Directive   Local Value Master Value
> mysqli.allow_local_infile   On  On
> mysqli.allow_persistent On  On
> mysqli.default_host no valueno value
> mysqli.default_port 33063306
> mysqli.default_pw   no valueno value
> mysqli.default_socket   no valueno value
> mysqli.default_user no valueno value
> mysqli.max_linksUnlimited   Unlimited
> mysqli.max_persistent   Unlimited   Unlimited
> mysqli.reconnectOff Off
> 
> The machine I compiled PHP on does not have mysqli.so, and so I am
> recieving the "fatal call to undefined function mysql_connect()"
> error. Can someone tell me how to compile php from source with mysql
> support, but actually mysql is installed on a different server?
> 
> Can I download a precompile mysqli anywhere? The PHP version is 5.1.49
> as noted earlier.
> 
> Thanks in Advance,
> 
> Nick


You've only compiled in MySQLi. You also need to pass --with-mysql to 
configure. As you can compile in MySQLi, you should have no problems with MySQL.

---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Bug #51739 tricky string to float conversion

2011-09-01 Thread Simon J Welsh
On 1/09/2011, at 8:43 PM, magic-...@damage.devloop.de wrote:

> Simon J Welsh writes: 
>> On 1/09/2011, at 9:53 AM, magic-...@damage.devloop.de wrote: 
>>> Am Mittwoch, 31. August 2011, 20:48:37 schrieb Shawn McKenzie:
>>>> On 08/31/2011 09:03 AM, magic-...@damage.devloop.de wrote:
>>>>> var_dump((float)"8315e839da08e2a7afe6dd12ec58245d");
>>>>> results in float(INF)
>>>> The cast to float is truncating the invalid characters and since your
>>>> string contains a float that is INF (8315e839) before the truncation at
>>>> the "d", then it returns INF.  Makes perfect sense.
>>> If I use a string in PHP I don't want PHP to cut this string. Either it 
>>> uses this string as it is or it gives me an error/warning/false (what 
>>> ever...). But silently(!!!) using a small piece of a string is not 
>>> understandable.
>> The manual clearly states this is how a string is converted into a number: 
>> http://php.net/manual/en/language.types.string.php#language.types.string.conversion
>>  "The value is given by the initial portion of the string. If the string 
>> starts with valid numeric data, this will be the value used. Otherwise, the 
>> value will be 0 (zero). Valid numeric data is an optional sign, followed by 
>> one or more digits (optionally containing a decimal point), followed by an 
>> optional exponent. The exponent is an 'e' or 'E' followed by one or more 
>> digits." If you don't want the string turned into a number using the 
>> documented method, don't use it as one.
> 
> Ok, then let's discuss the documented behavior ;-) 
> Do you (not the document) really like this behavior? I mean if I am the only 
> one wondering about that behavior it is ok for me. I just want to help PHP. 
> cheers
> Daniel

Yes, I think the way it works is correct.

It follows similar conversions when changing from a data type that allows more 
data to one that allows less. Similar things happen when converting from a 
floating point to integral value.

It also directly correlates to the C functions for doing the same thing (atof, 
strtod, the like).
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Bug #51739 tricky string to float conversion

2011-09-01 Thread Simon J Welsh
On 1/09/2011, at 9:53 AM, magic-...@damage.devloop.de wrote:

> Am Mittwoch, 31. August 2011, 20:48:37 schrieb Shawn McKenzie:
>> On 08/31/2011 09:03 AM, magic-...@damage.devloop.de wrote:
>>> Hi,
>>> I have opend Bug #51739 in 2010. It was closed as bogus before my last
>>> question was answered. It would be fine to know what you think about
>>> that bug.
>>> In short:
>>> var_dump((float)"8315e839da08e2a7afe6dd12ec58245d");
>>> results in float(INF)
>>> This is because "8315" is treated as base and
>>> "e839da08e2a7afe6dd12ec58245d" is treated as an exponent. My hint that
>>> "e839da08e2a7afe6dd12ec58245d" is not a valid exponent was not answered.
>>> What do you think about?
>>> cheers
>>> Daniel
>> 
>> The cast to float is truncating the invalid characters and since your
>> string contains a float that is INF (8315e839) before the truncation at
>> the "d", then it returns INF.  Makes perfect sense.
> 
> This is what drives me crazy.
> 
> If I use a string in PHP I don't want PHP to cut this string. Either it uses 
> this string as it is or it gives me an error/warning/false (what ever...). 
> But 
> silently(!!!) using a small piece of a string is not understandable.
> 
> cheers
> Daniel

The manual clearly states this is how a string is converted into a number: 
http://php.net/manual/en/language.types.string.php#language.types.string.conversion

"The value is given by the initial portion of the string. If the string starts 
with valid numeric data, this will be the value used. Otherwise, the value will 
be 0 (zero). Valid numeric data is an optional sign, followed by one or more 
digits (optionally containing a decimal point), followed by an optional 
exponent. The exponent is an 'e' or 'E' followed by one or more digits."

If you don't want the string turned into a number using the documented method, 
don't use it as one.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] how catch a warning by file_put_contents() ?

2011-08-19 Thread Simon J Welsh
On 20/08/2011, at 4:51 PM, Andreas wrote:

> Hi,
> I wrote stuff with file_put_contents() in a try{} catch{} and it worked.
> 
> Then I'd like to check what happens when some error occurs so I 
> writeprotected the targetfile.
> Instead of getting my own message by the catch{} block I got a standard 
> warning in the browser.
> 
> Can't I catch those warnings, too?
> And why does this function rise a warning when it can't acomplish it's task?
> 
> 
> Samplecode:
>try {
>$msg = date ("d.m.Y H:i:s") . 'This should be stored in the file.';
>file_put_contents( '/tmp/exceptions.txt', $msg . "\n", FILE_APPEND);
>}
>catch ( Exception $e ) {
>$msg = "Exception " . $e->getCode() . " / " . $e->getMessage();
>echo "$msg";
>}

file_put_contents() doesn't throw exceptions. As the note on the exception 
documentation says: "Internal PHP functions mainly use Error reporting, only 
modern Object oriented extensions use exceptions."

If you look at the documentation for its return value 
(http://php.net/file_put_contents), you'll see that false is returned on 
failure.

In this case, a warning makes more sense than throwing an exception anyway. A 
warning can be ignored, either by changing the error_reporting level or using 
the error control operator, whereas an exception must be dealt with or 
execution halts.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Using function prototypes in code

2011-08-10 Thread Simon J Welsh
On 10/08/2011, at 1:10 PM, Frank Thynne wrote:

> To confuse me a bit further, I can't find a definitive list of the
> basic type names. For example, is it "integer" or "int"?

Both. 
http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] A php bug or?..

2011-08-08 Thread Simon J Welsh
On 9/08/2011, at 8:20 AM, Andre Polykanine wrote:

> Hi everyone,
> 
>As we all know, count() returns 1 if the variable 
> is not an array.
> Question is: why in the world does it this? If a variable is *notA* an array, 
> it contains *zero* array elements.
> You can answer: "but no, man, you can say
> $x="world";
> $y=$x{3}; // $y="l"
> 
> so the variable is treated or can be treated as an array".
> Well. If strings are treated like arrays, why count($x) doesn't return 5 
> instead of 1?
> Just asking.
> 
> -- 
> With best regards from Ukraine,
> Andre

I'm assuming it has to do with the value, if not an array or object, being cast 
as an array. Thus, non-false equivalent values get cast into an array of size 1:

  int(1)
}
array(0) {
}

---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] put code into a function then the code dead,very strange.

2011-08-02 Thread Simon J Welsh
On 2/08/2011, at 10:24 PM, Sharl.Jimh.Tsin wrote:

> hi,everyone
>   it is a very strange problem,At first,i put my code into the method
> inner,it works.see below:
> 
> [snip]
> 
> As you can see,it seems to be impossible.Can someone tell me WHY?
> 
> -- 
> Best regards,
> Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**)

You're using $motoCols in your function, but have not defined it or passed it 
as an argument.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] is_null() and is_string() reversed when using in switch case statements...

2011-07-14 Thread Simon J Welsh
On 15/07/2011, at 1:58 PM, Daevid Vincent wrote:

> function test($v)
> {
>   var_dump($v);
> 
>   if (is_string($v)) echo "FOUND A STRING.\n";
>   if (is_null($v)) echo "FOUND A NULL.\n";
> 
>   switch ($v)
>   {
>   case is_string($v):
>   echo "I think v is a string, so this is broken.\n";
>   break;
>   case is_null($v):
>   echo "I think v is null, so this is broken.\n";
>   break;
>   case is_object($v):
>   $v = '{CLASS::'.get_class($v).'}';
>   echo "I think v is a class $v\n";
>   break;
> 
>   case is_bool($v):
>   $v = ($v) ? '{TRUE}' : '{FALSE}';
>   echo "I think v is boolean $v\n";
>   break;
>   case is_array($v):
>   $v = '['.implode(',',$v).']';
>   echo "I think v is an array $v\n";
>   break;
>   case is_numeric($v):
>   echo "I think v is a number $v\n";
>   break;
>   }
> }

In both cases, $v is equivalent to false, so is_string(NULL) = false == NULL == 
$v, likewise for is_null($v);

You're most likely after switch(true) { … } rather than switch($v)
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Spam filtering (was Top Posting)

2011-07-06 Thread Simon J Welsh
On 7/07/2011, at 5:50 AM, Jim Lucas wrote:

> On 7/5/2011 7:52 PM, Jim Giner wrote:
>> And what do you use to cut down on spam in your in-box? 
> 
> This is completely off topic, but here it goes...
> 
> When I received an email the other day from your mail server, I had created 
> this
> crazy ass reply to your automatic request for a reply.  But in turn, just sent
> the email with the link showing that your mail server is a source of spam.
> 
> To answer your question, I use built in Postfix checks...
> 
> Here are my list of options:
> 
> reject_invalid_hostname,
> reject_non_fqdn_hostname,
> reject_non_fqdn_sender,
> reject_non_fqdn_recipient,
> reject_unknown_sender_domain,
> reject_unknown_reverse_client_hostname,
> reject_unknown_recipient_domain,
> check_recipient_maps,
> permit_mynetworks,
> permit_sasl_authenticated,
> reject_unauth_destination,
> check_helo_access hash:/etc/postfix/helo_checks,
> reject_invalid_helo_hostname,
> reject_non_fqdn_helo_hostname,
> reject_unknown_helo_hostname,
> reject_rbl_client zen.spamhaus.org,
> reject_rbl_client psbl.surriel.com,
> reject_rbl_client korea.services.net,
> permit
> 
> With the above settings, I REJECT 99.9% of all SPAM that tries to enter my 
> box.
> 
> You are currently listed in my /etc/postfix/helo_checks file as
> 
> 64.118.87.45  REJECT Your mail server is a source of SPAM.  Fix it!

I use grey-listing. It temporarily rejects emails from servers it doesn't 
recognise, which stops most spam but actual email gets through as they 
(correctly) retry.

I also have a learning bayesian filter running in my mail client (Apple's 
Mail), which handles the spam that gets through the greylist.
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 10:14 AM, Scott Baker wrote:

> On 06/22/2011 03:06 PM, Simon J Welsh wrote:
>> On further inspection, that's not the problem at all. The problem's around 
>> assign_children($pid,$list,&$new);
>> 
>> The previous line you defined $new with $new = $leaf[$pid], *copying* that 
>> node into $new. Thus the assign_children() call updates $new, but not 
>> $lead[$pid].
>> 
>> You can fix this by either assigning $new by reference ($new =& $leaf[$pid]) 
>> or by passing a reference to $lead[$pid] to assign_children instead of $new.
> 
> I updated the code:
> 
> http://www.perturb.org/tmp/tree.txt
> 
> I still get the same output though. Only one level of depth :(

You still need to pass the value by reference to assign_children(), so:
$new = &$leaf[$pid];
assign_children($pid,$list,&$new);
---
Simon Welsh
Admin of http://simon.geek.nz/


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



Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 9:57 AM, Simon J Welsh wrote:

> On 23/06/2011, at 9:53 AM, Scott Baker wrote:
> 
>> I have a bunch of records in a DB that look like
>> 
>> id | parent_id
>> --
>> 1  | 4
>> 2  | 4
>> 3  | 2
>> 4  | 0
>> 5  | 2
>> 6  | 1
>> 7  | 3
>> 8  | 7
>> 9  | 7
>> 
>> I want to build a big has that looks like:
>> 
>> 4 -> 1 -> 6
>> -> 2 -> 3 -> 7 -> 9
>>  -> 5  -> 8
>> 
>> I'm like 90% of the way there, but I can't get my recursive assignment
>> to work. Has anyone done this before that could offer some pointers?
>> Here is my sample code thus far:
>> 
>> http://www.perturb.org/tmp/tree.txt
>> 
>> I can get one level of depth, but nothing more than that :(
> 
> I haven't looked that much into your code, but:
> $children = find_children($id,$list);
> 
> $list is never defined.

On further inspection, that's not the problem at all. The problem's around 
assign_children($pid,$list,&$new);

The previous line you defined $new with $new = $leaf[$pid], *copying* that node 
into $new. Thus the assign_children() call updates $new, but not $lead[$pid].

You can fix this by either assigning $new by reference ($new =& $leaf[$pid]) or 
by passing a reference to $lead[$pid] to assign_children instead of $new.

---
Simon Welsh
Admin of http://simon.geek.nz/


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



  1   2   3   4   5   6   >