Re: [PHP-DOC] Hello and questions

2013-10-20 Thread Sherif Ramadan
On Sun, Oct 20, 2013 at 7:31 AM, Dan Ackroyd  wrote:

> Hi,
>
> I've started out tackling the vast number of Imagick functions that have
> either no documentation at all, or lack examples. A couple of questions:
>
> 1) Should I submit a separate patch per change? Standard best practice is
> usually to do that, but seeing as it's SVN and may take time to merge each
> patch, would it make the people who are merging changes lives easier to
> have fewer patches?
>

Yes. Submit a separate patch for each change.


>
> 2) Are there any guidelines on adding images to the doc? Some of the
> Imagick functions would seem to benefit from a pictorial example as they're
> much easier to explain visually than with text. If they're allowed, what
> size can be used and is there a recommended colour scheme?
>

Not really, but employ common sense where possible. i.e. we don't need
1920x1024 pixel images as examples.


>
> 3) Some methods are missing from the Imagick classes, and some are not
> marked as static when they should be. Is it possible for these to be edited
> online, or does that need to be generated from the source code? For example
> the page http://www.php.net/manual/en/class.imagickpixel.php seems to
> have the function list pulled in from somewhere else:
>
>http://docbook.org/ns/docbook)
> xpointer(id('class.imagickpixel')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])"
> />
>
>   
>  
>  &reference.imagick.entities.imagickpixel;
>
>
Which methods are missing and from what classes? To mark a class as
static/public/etc.. you simply apply a modifier tag to its methodsynopsis.
For example, in
/en/reference/imagick/imagickpixel/.xml there
will be a  entity towards the beginning of the file. For
example in getcolor.xml there is the following:


  arrayImagickPixel::getColor
...

Just add static if the method should be static, for
example.


> 4) As much fun as it is being 'anonymous #33522' please could I have a
> login for the online editor?
>
>
You can login to the online doc editor with a facebook/google login, I
believe, if you don't want to log in anonymously. It doesn't make much of a
difference. The OE is just a way for everyone to contribute to the docs
with minimal bar-to-entry. If you'd like to contribute to the documentation
regularly you'll want to familiarize yourself with our tool-chain. See
https://wiki.php.net/doc/howto and
https://wiki.php.net/doc/howto/gettingstarted


> cheers
> Dan
>


Re: [PHP-DOC] Blocked pages in the online editor.

2013-08-01 Thread Sherif Ramadan
On Thu, Aug 1, 2013 at 9:44 PM, Niel Archer  wrote:

> A number of times over the last year I've seen documentation bugs
> reported I could fix myself with the online editor. Only to find when
> attempting to do so, that they were blocked by a previous edit that has
> not been commited as a patch. A good example of this is a recent bug
> report:
> https://bugs.php.net/bug.php?id=65370
> I beleive this is the second time a similar comment has been made on
> this page and I have found the page still blocked by edits made by an
> anonymous user 24488.
>
> Is there any way that older saved edits can either be reviewed and
> commited/dropped or failing that just dropped after a reasonable amount
> of time has passed.
>
> I believe in most cases that the user making these edits has not
> realised that saving them does not automatically commit and that they
> need to make a separate patch for that to happen.
> --
> Niel Archer
>
>
I've cleared the changes in the online editor for the file indicated in bug
65370.

If the user does not submit their changes as a patch others users in the
online editor without admin rights will not be able to modify the same file.

Let me know if there is any other specific pages in the manual you are
trying to edit that are currently locked due to pending changes and I will
be happy to take a look.

Thanks,
Sherif


[PHP-DOC] Re: [PHP-DEV] Moving PHP documentation to Git repository

2013-06-25 Thread Sherif Ramadan
On Tue, Jun 25, 2013 at 5:10 AM, Johannes Schlüter
wrote:

> On Tue, 2013-06-25 at 08:46 +0200, Christian Stoller wrote:
> > Hi internals.
> >
> > What do you think about moving the PHP documentation to a Git
> > repository, mirrored on Github? Doing this would make it possible for
> > everybody to extend the documentation easily by creating pull
> > requests.
>
> Basically that is good. To the best of my knowledge the issue though, is
> not will but time. Migrating the docs is not just converting the repo,
> like with PECL repos but changing the supporting infrastructure. For
> instance there are tools which help to identify outdated translations
> and the mentioned editor which all have to be adopted. If you want to
> help there the docs group certainly would welcome it.
>
> That aside: resources is also the issue with the online editor. We have
> too few people working on docs, so in the end it doesn't make much
> difference if they don't have time to review edit.php.net or github.
> (while reviewing on edit.php.net has the benefit that it can directly
> validate the docbook, github can't)
>

I'm all for docs moving to git, but I have to say it would be a purely
cosmetic move. This won't change the pace at which our patches are getting
through or the fact that the lack of man-power can be overwhelming for
docs. The documentation is over 10,000 pages and growing with multiple
translations. PHP also suffers from a problem where patches go into php-src
that never get into the changelog for some reason and end up becoming
documentation bugs. I've definitely fixed a number of those in
bugs.php.netand I know I'm not the only one that has complained about
this problem.
It's hard to keep up with the pace at which PHP changes and consistently
document that.

I will say that we do need more people helping out with docs before we
should consider investing the resources in moving docs to git. Again, this
move would only serve to be superficial in the long-run.


>
> johannes
>   (who is one of the bad people not really actively helping with docs)
>

So YOU'RE the one! (*kidding* it's been a while since I've made some
commits myself)


>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DOC] VCS Account Request: whatthejeff

2013-06-20 Thread Sherif Ramadan
On Thu, Jun 20, 2013 at 4:07 PM, Hannes Magnusson <
hannes.magnus...@gmail.com> wrote:

> Done, welcome to the team!
>
> -Hannes
>
> On Tue, Jun 18, 2013 at 6:52 PM, Jeff Welch  wrote:
> > Hi, all :)
> >
> > My name is Jeff Welch and I\'m one of the maintainers of the
> PHPUnit project.
> >
> > In the past year, I have made a couple contributions to the PHP project:
> >
> >  *
> http://git.php.net/?p=php-src.git;a=commit;h=c4686b4de93a89e8265331b0d4a6a7954ccbae95
> >  *
> https://svn.php.net/viewvc?limit_changes=0&view=revision&revision=330543
> >
> > I have also made small contributions to a number of PHP extensions,
> including:
> >
> >  * https://github.com/php-test-helpers/php-test-helpers
> >  * https://github.com/m4rw3r/php-libev
> >  * https://github.com/chobie/php-uv
> >  * http://xdebug.org/
> >
> > I have also written a PHP extension which I plan to submit to PECL as
> soon as I have some time to work on portability (and maybe update the
> interface to satisfy https://wiki.php.net/rfc/escaper):
> >
> >  * https://github.com/whatthejeff/houdini-for-php
> >
> > Anyway, I\'d like to request a Git account so I can more easily
> contribute to the documentation and so I can work towards being a more
> active contributor to PHP core in the future. I don\'t know too many
> existing account holders, but I believe Sebastian Bergmann can vouch that I
> probably won\'t do anything too irresponsible if granted an account.
> >
> > Thanks,
> >
> > - Jeff
> >
>


Welcome aboard! Great job and thanks on that last patch btw.


Re: [PHP-DOC] Re: OPCache documentation

2013-06-20 Thread Sherif Ramadan
On Thu, Jun 20, 2013 at 5:51 PM, Adam Harvey  wrote:

>
> I'm working on some basic opcache documentation as we speak, since it
> was pointed out on #php.doc. That said, mostly what I'm doing for now
> is adapting the README in ext/opcache and documenting opcache_reset()
> and opcache_invalidate() — some additional theory of operating and
> setup documentation would be very welcome.
>
> There should be something to look at in SVN in the next hour or so.
>
> My apologies — I wrote the first draft of the migration guide in the
> mid alpha stage (ie before opcache was merged) of 5.5 with the
> intention of going back to flesh it out before the final release, but
> time has been a bit of an issue. Turns out moving halfway across the
> world is a real time sink.
>
>

Thank you for working on that. I will dig into opcache over the next few
days and see if I can lend a hand.



> Adam
>


Re: [PHP-DOC] Re: OPCache documentation

2013-06-20 Thread Sherif Ramadan
On Thu, Jun 20, 2013 at 5:36 PM, Julien Pauli  wrote:

> On Wed, May 15, 2013 at 3:54 PM, Julien Pauli  wrote:
>
>> Hi all,
>>
>> As you know, 5.5 final is coming soon.
>> We are in RC, so mainly stabilizing stuff and preparing the final release
>> for anyone to setup 5.5 on their servers.
>>
>> I see the documentation migration guide has already been commited, that's
>> a good new.
>> I also see that new features we ship in 5.5 are online in the
>> documentation, great !
>>
>> But a crucial feature is missing doc : OPCache.
>>
>> As this feature is a very big step in PHP's life (we finally have a
>> recommanded, bundled opcode cache system, and I'm very proud of this
>> personnaly), I think it is crucial to have a good documentation about it.
>>
>> Has anyone started to write some doc about OPCache ?
>>
>> Another subject is APC. We have its doc on php.net, all right.
>> What I would like is we patch APC doc when 5.5 final gets released, to
>> clearly show our mind about it.
>> That way, any people using 5.5 should be able to read in the doc that APC
>> has support has been interrupted, that APC should never be used together
>> with OPCache, and that OPCache is now the standard recommanded OPCode
>> caching solution for 5.5, 5.4 and 5.3.
>>
>> It is crucial to communicate one this point for our users.
>>
>> Then will come the "User cache" debate
>>
>> Thank you.
>>
>
>
> Up. Could we at least plan such a project ?
> 5.5 is released now. I know we are still having trouble about OpCache
> particulary under Windows. I dont shadow that.
> I would just like we start thinking about writing documentation for
> OPCache features and merge them to our official documentation. If it's
> already planned by someone, just let me know ;-)
>
>
I find it hard to believe this feature made it into 5.5.0 without
a shred of documentation. I would be willing to help, but I actually don't
know much about how opcache works. If anyone is willing to give me a hand I
could draft up some basic FAQ style docs at least so that 5.5.0 users will
have some point of reference.


> Thx.
>
> Julien.Pauli
>


Re: [PHP-DOC] Introduction + Missing static modifiers

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 1:36 PM, Jeff Welch  wrote:

>
>>> I wouldn't mind having a CVS account, though :P
>>>
>>>
 I'd say head over to http://www.php.net/git-php.php read the page
carefully, and fill out a request for an account. Include that you've
submitted the patch from the svn revision above.


Re: [PHP-DOC] Introduction + Missing static modifiers

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 1:23 PM, Jeff Welch  wrote:

> On Jun 18, 2013, at 1:13 PM, Sherif Ramadan 
> wrote:
>
> On Mon, Jun 17, 2013 at 12:50 PM, Jeff Welch wrote:
>
>> On Sun, Jun 16, 2013 at 6:51 PM, Jeff Welch wrote:
>>
>>> On Sun, Jun 16, 2013 at 10:57 AM, Jeff Welch wrote:
>>>
>>>> On Sun, Jun 16, 2013 at 4:36 AM, Sherif Ramadan <
>>>> theanomaly...@gmail.com> wrote:
>>>>
>>>>>
>>>>> On Sun, Jun 16, 2013 at 3:40 AM, Jeff Welch wrote:
>>>>>
>>>>>> Hi, all :)
>>>>>>
>>>>>> My name is Jeff Welch and I'm one of the maintainers of the PHPUnit
>>>>>> project. While investigating a PHPUnit issue (
>>>>>> https://github.com/sebastianbergmann/phpunit-mock-objects/issues/130)
>>>>>> this past friday, I noticed that the PHP documentation is missing the
>>>>>> static modifier for a number of methods. I've created a patch (
>>>>>> https://gist.github.com/whatthejeff/5790970) that adds the missing
>>>>>> modifier for the following methods:
>>>>>>
>>>>>>  * `MessageFormatter::create`
>>>>>>  * `MessageFormatter::formatMessage`
>>>>>>  * `MessageFormatter::parseMessage`
>>>>>>  * `mysqli::poll`
>>>>>>  * `Phar::apiVersion`
>>>>>>  * `Phar::canCompress`
>>>>>>  * `Phar::canWrite`
>>>>>>  * `Phar::createDefaultStub`
>>>>>>  * `Phar::getSupportedCompression`
>>>>>>  * `Phar::getSupportedSignatures`
>>>>>>  * `Phar::interceptFileFuncs`
>>>>>>  * `Phar::isValidPharFilename`
>>>>>>  * `Phar::loadPhar`
>>>>>>  * `Phar::mapPhar`
>>>>>>  * `Phar::running`
>>>>>>  * `Phar::mount`
>>>>>>  * `Phar::mungServer`
>>>>>>  * `Phar::unlinkArchive`
>>>>>>  * `Phar::webPhar`
>>>>>>  * `SQLite3::version`
>>>>>>  * `SQLite3::escapeString`
>>>>>>
>>>>>> Anyway, it would be nice to get VCS access so I don't have to jump
>>>>>> through too many hoops for future contributions.
>>>>>>
>>>>>> PS: I've heard a love for cats will get you far with this list, so I
>>>>>> submit to you my cat-related open source contributions:
>>>>>>
>>>>>>  * https://github.com/whatthejeff/nyancat-phpunit-resultprinter
>>>>>>  * https://github.com/phpspec/phpspec/pull/133
>>>>>>  * https://github.com/whatthejeff/nyancat-scoreboard
>>>>>>
>>>>>>
>>>>>
>>>>> Hey you cheated. There was a dinosaur in there!
>>>>>
>>>>> Looks OK, but I suspect that it would be even better to add the
>>>>> visibility modifiers as long as you're adding the access modifiers.
>>>>>
>>>>
>>>> I can agree to this.
>>>>
>>>>
>>>>> The documentation is currently wishy-washy about having those for all
>>>>> of the classes. Some have just the access and others have both visibility
>>>>> and access. If you'd be willing to help fix the rest that would be awesome
>>>>>
>>>>
>>>> I don't mind adding the missing visibility modifiers.
>>>>
>>>
>>> Alright, I've updated the patch (
>>> https://gist.github.com/whatthejeff/5790970) to include visibility
>>> modifiers. For the most part I only worked on core classes as I don't have
>>> time to go through all the available PECL classes. I can't guarantee that I
>>> caught them all, but I did my best :)
>>>
>>
>> I realize this diff will be very time consuming to verify manually, so
>> I've added a script that parses the modifiers from my diff and verifies
>> them through reflection.
>>
>> You can find the script here:
>> https://gist.github.com/whatthejeff/5790970#file-test-missing-modifiers-php
>> And the output here:
>> https://gist.github.com/whatthejeff/5790970#file-output
>>
>>  Hopefully this helps :)
>>
>>
>>>
>>>>
>>>>> and I'm sure the cats will give you bonus points for your VCS account.
>>>>>
>>>>> You also might want to take a look at https://edit.php.net
>>>>>
>>>>
>>>> Yeah, I looked into that, but it's also nice to use shell tools for
>>>> making mass changes. For instance, I found all the missing static modifiers
>>>> and patched the documentation using grep/awk/sed.
>>>>
>>>>
>>>>> If no one has any objections I'll go ahead and apply your patch later
>>>>> tonight. I admit I didn't look it over that thoroughly.
>>>>>
>>>>
>>>> I can tell you that I compiled all the sources and manually verified
>>>> that the changed pages look as expected. We use DocBook for PHPUnit's
>>>> documentation, so I have a decent amount of experience with this toolchain.
>>>>
>>>>
>>>>>
>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> - Jeff
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
> Wow, this patch is huge and scary. Maybe we should give you a CVS account
> so that you can patch it yourself? :P
>
>
> Actually, I cheated and asked Sebastian Bergmann to patch it for me last
> night:
>
>
That would explain why svn is telling me the patch failed when I tried to
run it through patch this morning :) I didn't update from trunk apparently.

Good job. 99 more patches like this and you get a free t-shirt!


> https://svn.php.net/viewvc?limit_changes=0&view=revision&revision=330543
>
> I wouldn't mind having a CVS account, though :P
>
> - Jeff
>


Re: [PHP-DOC] Introduction + Missing static modifiers

2013-06-18 Thread Sherif Ramadan
On Mon, Jun 17, 2013 at 12:50 PM, Jeff Welch  wrote:

> On Sun, Jun 16, 2013 at 6:51 PM, Jeff Welch  wrote:
>
>> On Sun, Jun 16, 2013 at 10:57 AM, Jeff Welch wrote:
>>
>>> On Sun, Jun 16, 2013 at 4:36 AM, Sherif Ramadan >> > wrote:
>>>
>>>>
>>>> On Sun, Jun 16, 2013 at 3:40 AM, Jeff Welch wrote:
>>>>
>>>>> Hi, all :)
>>>>>
>>>>> My name is Jeff Welch and I'm one of the maintainers of the PHPUnit
>>>>> project. While investigating a PHPUnit issue (
>>>>> https://github.com/sebastianbergmann/phpunit-mock-objects/issues/130)
>>>>> this past friday, I noticed that the PHP documentation is missing the
>>>>> static modifier for a number of methods. I've created a patch (
>>>>> https://gist.github.com/whatthejeff/5790970) that adds the missing
>>>>> modifier for the following methods:
>>>>>
>>>>>  * `MessageFormatter::create`
>>>>>  * `MessageFormatter::formatMessage`
>>>>>  * `MessageFormatter::parseMessage`
>>>>>  * `mysqli::poll`
>>>>>  * `Phar::apiVersion`
>>>>>  * `Phar::canCompress`
>>>>>  * `Phar::canWrite`
>>>>>  * `Phar::createDefaultStub`
>>>>>  * `Phar::getSupportedCompression`
>>>>>  * `Phar::getSupportedSignatures`
>>>>>  * `Phar::interceptFileFuncs`
>>>>>  * `Phar::isValidPharFilename`
>>>>>  * `Phar::loadPhar`
>>>>>  * `Phar::mapPhar`
>>>>>  * `Phar::running`
>>>>>  * `Phar::mount`
>>>>>  * `Phar::mungServer`
>>>>>  * `Phar::unlinkArchive`
>>>>>  * `Phar::webPhar`
>>>>>  * `SQLite3::version`
>>>>>  * `SQLite3::escapeString`
>>>>>
>>>>> Anyway, it would be nice to get VCS access so I don't have to jump
>>>>> through too many hoops for future contributions.
>>>>>
>>>>> PS: I've heard a love for cats will get you far with this list, so I
>>>>> submit to you my cat-related open source contributions:
>>>>>
>>>>>  * https://github.com/whatthejeff/nyancat-phpunit-resultprinter
>>>>>  * https://github.com/phpspec/phpspec/pull/133
>>>>>  * https://github.com/whatthejeff/nyancat-scoreboard
>>>>>
>>>>>
>>>>
>>>> Hey you cheated. There was a dinosaur in there!
>>>>
>>>> Looks OK, but I suspect that it would be even better to add the
>>>> visibility modifiers as long as you're adding the access modifiers.
>>>>
>>>
>>> I can agree to this.
>>>
>>>
>>>> The documentation is currently wishy-washy about having those for all
>>>> of the classes. Some have just the access and others have both visibility
>>>> and access. If you'd be willing to help fix the rest that would be awesome
>>>>
>>>
>>> I don't mind adding the missing visibility modifiers.
>>>
>>
>> Alright, I've updated the patch (
>> https://gist.github.com/whatthejeff/5790970) to include visibility
>> modifiers. For the most part I only worked on core classes as I don't have
>> time to go through all the available PECL classes. I can't guarantee that I
>> caught them all, but I did my best :)
>>
>
> I realize this diff will be very time consuming to verify manually, so
> I've added a script that parses the modifiers from my diff and verifies
> them through reflection.
>
> You can find the script here:
> https://gist.github.com/whatthejeff/5790970#file-test-missing-modifiers-php
> And the output here:
> https://gist.github.com/whatthejeff/5790970#file-output
>
>  Hopefully this helps :)
>
>
>>
>>>
>>>> and I'm sure the cats will give you bonus points for your VCS account.
>>>>
>>>> You also might want to take a look at https://edit.php.net
>>>>
>>>
>>> Yeah, I looked into that, but it's also nice to use shell tools for
>>> making mass changes. For instance, I found all the missing static modifiers
>>> and patched the documentation using grep/awk/sed.
>>>
>>>
>>>> If no one has any objections I'll go ahead and apply your patch later
>>>> tonight. I admit I didn't look it over that thoroughly.
>>>>
>>>
>>> I can tell you that I compiled all the sources and manually verified
>>> that the changed pages look as expected. We use DocBook for PHPUnit's
>>> documentation, so I have a decent amount of experience with this toolchain.
>>>
>>>
>>>>
>>>>
>>>>> Thanks,
>>>>>
>>>>> - Jeff
>>>>>
>>>>
>>>>
>>>
>>
>

Wow, this patch is huge and scary. Maybe we should give you a CVS account
so that you can patch it yourself? :P


Re: [PHP-DOC] Re: strlen and multi-byte characters

2013-06-17 Thread Sherif Ramadan
On Mon, Jun 17, 2013 at 1:18 PM, Adam Harvey  wrote:

> On 16 June 2013 15:37, Sherif Ramadan  wrote:
> > I have no clue how you're getting that result.
>
> What are your respective mbstring.func_overload settings, out of interest?
>
>
mbstring.func_overload is off. Doesn't seem to make a difference if I turn
it on either. I suppose there is some encoding that must be explicitly
specified for mbstring.func_overloading to get it right.


> Adam
>


Re: [PHP-DOC] Documentation for an extension

2013-06-17 Thread Sherif Ramadan
On Mon, Jun 17, 2013 at 11:22 AM, Jeroen Moors wrote:

> Hi,
>
> I'm new to the list, so I hope this is the right place to ask my question,
> if not, my excuses!
>
> Currently I'm working on a PHP extension for Ceph (
> https://github.com/ceph/phprados/).It's
> not yet ready to be adopted by PECL.
>
> I would like to create already some documentation on it's API, preferably
> in such a way that if one day it's moving upstream a could reuse the
> existing documentation.
>
> I've already did some research about which tools could be used, but it's
> still a bit unclear to me what's currently the best way to go.
>
> Any advice is welcome!
>

You could start here https://wiki.php.net/doc/scratchpad/pecldocs where
there is a guide for building pecl docs in the wiki. Currently pecl
extensions are documented along with the regular PHP documentation
available at php.net so you would need to get familiar wtih phd and the
toolchain used there. So these links may come in handy as well
https://wiki.php.net/doc/articles and https://wiki.php.net/doc/phd

Good luck.


>
> Thanks!
>
> Jeroen
>


Re: [PHP-DOC] Re: strlen and multi-byte characters

2013-06-16 Thread Sherif Ramadan
On Sun, Jun 16, 2013 at 1:54 PM, Andrey Pashentsev wrote:

> **
> Below is what I got (php5.4):
> 1)
> Script is in utf-8 with BOM encoding. zend.multibyte is enabled
> (to use this feature, mbstring extension must be enabled).
>  echo strlen('ы'); //russian letter
> $str = 'äå';
> echo "\n" . strlen($str);
> ?>
>
> Output:
> 1
> 2
>
> 2)
> Script is in utf-8 encoding. zend.multibyte is disabled.
>  echo strlen('ы');
> $str = 'äå';
> echo "\n" . strlen($str);
> ?>
>
> Output:
> 2
> 4
>
>

I have no clue how you're getting that result.

If I run your code with zend.multibyte enabled I still get the same results
as I do with it turned off.

var_dump(ini_get('zend.multibyte'));
echo strlen('ы'); //russian letter
$str = 'äå';
echo "\n" . strlen($str);


/* Output */

string(1) "1"
2
4


Nowhere do I see zend.multibyte documented to affect the behavior of strlen
anywhere in the code or the documentation. This configuration is clearly
documented to affect the way the engine parses the source files. I can't
reproduce what you're saying and I also can't find a single line of code in
the source to support your claim.



>  "Sherif Ramadan"  сообщил/сообщила в новостях
> следующее:
> news:cal+t6cgpn+vnzak+g5i-c4cjllsorweal7rbhco38-t_7ow...@mail.gmail.com...
>
>
>
> On Sun, Jun 16, 2013 at 3:51 AM, Andrey Pashentsev wrote:
>
>>
>> "Adam Kazimierczak"  сообщил/сообщила в новостях
>> следующее: news:51BA2CC5.3060508@gmail.**com...
>>
>> Hello Mailing List,
>>>
>>> I found that strlen is often considered as a function that counts
>>> characters in strings, rather than bytes. Such mistake is even often
>>> seen on blogs or tutorials, so many PHP beginners may get confused when
>>> they try to strlen a multi-byte characters string.
>>>
>>> I am attaching a patch proposition where the description notes that
>>> length is measured in bytes and adds an example showing results of
>>> strlen used on multi-byte character strings.
>>>
>>> Please let me know what do you think about this.
>>>
>>> Cheers,
>>> Adam
>>>
>>>
>> Hi Adam
>>
>>
>> I found that strlen is often considered as a function that counts
>>> characters in strings, rather than bytes.
>>>
>>
>> Don't forget about zend.multibyte feature...
>>
>> If it is on and you have a script in 'utf-8 with BOM' encoding
>> php will detect it and strlen will take this into account.
>>
>>
> zend.multibyte enables the PHP engine to parse source files that are in
> multibyte encodings. It has nothing to do with the behavior of strlen, nor
> does it change the behavior of the function.
>
>
>>
>> Cheers,
>> Andy
>>
>>
>


Re: [PHP-DOC] strlen and multi-byte characters

2013-06-16 Thread Sherif Ramadan
On Thu, Jun 13, 2013 at 4:34 PM, Adam Kazimierczak wrote:

> Hello Mailing List,
>
> I found that strlen is often considered as a function that counts
> characters in strings, rather than bytes. Such mistake is even often seen
> on blogs or tutorials, so many PHP beginners may get confused when they try
> to strlen a multi-byte characters string.
>
> I am attaching a patch proposition where the description notes that length
> is measured in bytes and adds an example showing results of strlen used on
> multi-byte character strings.
>
> Please let me know what do you think about this.
>

+1 from me.


>
> Cheers,
> Adam
>


Re: [PHP-DOC] Re: strlen and multi-byte characters

2013-06-16 Thread Sherif Ramadan
On Sun, Jun 16, 2013 at 3:51 AM, Andrey Pashentsev wrote:

>
> "Adam Kazimierczak"  сообщил/сообщила в новостях
> следующее: news:51BA2CC5.3060508@gmail.**com...
>
>  Hello Mailing List,
>>
>> I found that strlen is often considered as a function that counts
>> characters in strings, rather than bytes. Such mistake is even often
>> seen on blogs or tutorials, so many PHP beginners may get confused when
>> they try to strlen a multi-byte characters string.
>>
>> I am attaching a patch proposition where the description notes that
>> length is measured in bytes and adds an example showing results of
>> strlen used on multi-byte character strings.
>>
>> Please let me know what do you think about this.
>>
>> Cheers,
>> Adam
>>
>>
> Hi Adam
>
>
>  I found that strlen is often considered as a function that counts
>> characters in strings, rather than bytes.
>>
>
> Don't forget about zend.multibyte feature...
>
> If it is on and you have a script in 'utf-8 with BOM' encoding
> php will detect it and strlen will take this into account.
>
>
zend.multibyte enables the PHP engine to parse source files that are in
multibyte encodings. It has nothing to do with the behavior of strlen, nor
does it change the behavior of the function.


>
> Cheers,
> Andy
>
>


Re: [PHP-DOC] Introduction + Missing static modifiers

2013-06-16 Thread Sherif Ramadan
On Sun, Jun 16, 2013 at 3:40 AM, Jeff Welch  wrote:

> Hi, all :)
>
> My name is Jeff Welch and I'm one of the maintainers of the PHPUnit
> project. While investigating a PHPUnit issue (
> https://github.com/sebastianbergmann/phpunit-mock-objects/issues/130)
> this past friday, I noticed that the PHP documentation is missing the
> static modifier for a number of methods. I've created a patch (
> https://gist.github.com/whatthejeff/5790970) that adds the missing
> modifier for the following methods:
>
>  * `MessageFormatter::create`
>  * `MessageFormatter::formatMessage`
>  * `MessageFormatter::parseMessage`
>  * `mysqli::poll`
>  * `Phar::apiVersion`
>  * `Phar::canCompress`
>  * `Phar::canWrite`
>  * `Phar::createDefaultStub`
>  * `Phar::getSupportedCompression`
>  * `Phar::getSupportedSignatures`
>  * `Phar::interceptFileFuncs`
>  * `Phar::isValidPharFilename`
>  * `Phar::loadPhar`
>  * `Phar::mapPhar`
>  * `Phar::running`
>  * `Phar::mount`
>  * `Phar::mungServer`
>  * `Phar::unlinkArchive`
>  * `Phar::webPhar`
>  * `SQLite3::version`
>  * `SQLite3::escapeString`
>
> Anyway, it would be nice to get VCS access so I don't have to jump through
> too many hoops for future contributions.
>
> PS: I've heard a love for cats will get you far with this list, so I
> submit to you my cat-related open source contributions:
>
>  * https://github.com/whatthejeff/nyancat-phpunit-resultprinter
>  * https://github.com/phpspec/phpspec/pull/133
>  * https://github.com/whatthejeff/nyancat-scoreboard
>
>

Hey you cheated. There was a dinosaur in there!

Looks OK, but I suspect that it would be even better to add the visibility
modifiers as long as you're adding the access modifiers. The documentation
is currently wishy-washy about having those for all of the classes. Some
have just the access and others have both visibility and access. If you'd
be willing to help fix the rest that would be awesome and I'm sure the cats
will give you bonus points for your VCS account.

You also might want to take a look at https://edit.php.net

If no one has any objections I'll go ahead and apply your patch later
tonight. I admit I didn't look it over that thoroughly.


> Thanks,
>
> - Jeff
>


Re: [PHP-DOC] VCS Account Request: kazymjir

2013-06-15 Thread Sherif Ramadan
On Sat, Jun 15, 2013 at 9:05 AM, Adam Kazimierczak wrote:

> Thank you very much!
>
> - Adam
>
>
> On 06/14/2013 07:57 PM, Hannes Magnusson wrote:
>
>> Approved & gave you karma for the en doc module.
>>
>> Nice to have you aboard!
>>
>> -Hannes
>>
>> On Thu, Jun 13, 2013 at 11:09 PM, Adam Kazimierczak 
>> wrote:
>>
>>> Philip Olson asked me to apply for an account
>>>
>>>
>

Welcome to the documentation team and thanks for all your hard work so far.

Another brave victim ... I mean soul!

-Sherif
There are keys on my keyboard. Sometimes I press them.


Re: [PHP-DOC] PHP Manual - Contribution

2013-06-03 Thread Sherif Ramadan
On Mon, Jun 3, 2013 at 1:49 PM, Evan Nabors wrote:

>  Hello,
>
>  My name is Evan and I am a technical writer that works for Rackspace
> Hosting.
>
>  This week I was using the online php manual to assist a customer with a
> PHP script. While looking through the online documentation I came across a
> section providing instructions on "Installing on Cloud Computing
> Platforms". To my dismay Rackspace did not have a presence on this page. I
> am interesting in writing content for the manual that would fill this gape.
> The content would add Rackspace to the list of available cloud providers
> and provide links to our product information and PHP SDK.
>
>  I read the getting_started section and noticed the first step was to
> introduce myself. I wanted to get this portion started while I got to work
> on cloning the book and beginning to include my content. Consider this my
> "Hello" fellow tech writers! I look forward to working with you all. Let me
> know if you have any questions/comments/concerns. If not I will get to work
> on cutting a build in the coming days.
>
>  Link Referenced - 
> http://www.php.net/manual/en/install.cloud.php
>
>
+1 on this.

This part of the manual is lacking in every way. Not just for Rackspace,
but even the existing services just point to the vendor documentation. It
would be nice to provide some actual meaty content here from the vendors.


>  Thanks!
> Evan Nabors
> Rackspace::Cloud('Product Evangelist')
>


Re: [PHP-DOC] Adding to current docs

2013-05-09 Thread Sherif Ramadan
On Thu, May 9, 2013 at 10:27 PM, Philip Olson  wrote:

>
>
Regards,
> Philip, guy who isn't around much these days
>


OMG, Philip is alive! I saw it.


>
>
> On May 9, 2013, at 6:12 PM, Jason Gerfen  wrote:
>
> > I am currently in the process of reviewing the guidelines, howto & and
> > other documentation to submit documentation for some new features added
> to
> > an existing extension.
> >
> > Just wanted to say hi and if anyone has any tips, pointers etc. please
> > share. Thanks!
> >
> > --
> > Jas
> > http://www.github.com/jas-
> >
> > 
>
>


[PHP-DOC] Re: [PHP-WEBMASTER] User notes guidelines.

2013-01-10 Thread Sherif Ramadan
On Thu, Jan 10, 2013 at 9:34 AM, Levi Morrison wrote:

> > Another way to look at this is if the function lacks something not
> otherwise
> > covered by another function. To elaborate I've seen user implementations
> of
> > count that work on multidimensional arrays. Obviously PHP has no similar
> > function. There is no count_recursive in PHP so I think that's fine and
> it's
> > fairly simple to implement in user land.
>
> Actually, there is an optional parameter you can supply for a
> recursive option. As such I have deleted all of the count_recursive
> code dumps except one. It had 3 upvotes and limited the depth of the
> recursion.
>

This just goes to show how much I actually read the manual :)


Re: [PHP-DOC] VCS Account Request: mikemike

2013-01-10 Thread Sherif Ramadan
On Thu, Jan 10, 2013 at 8:59 AM, Mike Griffiths wrote:

>
> On 10 January 2013 13:36, Mike Griffiths  wrote:
>
>> Maintaining user notes (not adding to them), submitting and committing
>> the odd documentation patch (I currently use the online editor for this).
>>  I\'m a regular on #php.doc
>>
>> And I'm a big fan of kittens, of course!
>


Pictures or it never happened!


Re: [PHP-DOC] Patch for bringing memcached extension docs up to date.

2013-01-04 Thread Sherif Ramadan
On Thu, Jan 3, 2013 at 10:47 PM, David Terei  wrote:

> Hi,
>
> Please review the patch below that brings the memcached extension docs
> up to date with the functionality in 2.0.0 and later.
>
> http://davidterei.com/downloads/phpdoc-memcached.patch
>
> Cheers,
> David
>


Looks good to me. If no one that's working on memcached sees any mistakes
I'll patch this on Monday.

Thank you for your contribution and for making the documentation better :)


Re: [PHP-DOC] PHP.net tutorials improvements

2013-01-03 Thread Sherif Ramadan
On Thu, Jan 3, 2013 at 12:04 AM, Philip Olson  wrote:

>
> Greetings all,
>
> Also, I reckon the main PHP tutorial should get someone started but not
> worry
> about all of the minor details along the way. An ideal tutorial might,
> let's
> say, allow someone to create a nice address book app or TODO manager, but
> not
> a framework. Said TODO manager should probably include JavaScript, although
> how far php.net should go with these related topics (e.g., CSS) is
> difficult
> to answer. Not very far, I guess.
>

There is a lot of foundation knowledge required to build and entire site
from scratch.

While I like the idea of having a tutorial on php.net that teaches you how
to build something that might actually be useful, I fear that it may prove
more useless than the existing tutorial to a beginner. My reasoning behind
this comes from past experience. When I first started learning PHP (back
when I was still on this ancient technology called dialup) I wasn't in the
least bit interested to read a tutorial that showed me how to build a
specific application. I was purely interested in finding the information I
needed to get done what I needed done at that time. PHP is a great language
where you can just take an idea you have in your head and start banging out
code to see if it works. We should be teaching beginners things like basic
syntax, operators, data types, looping constructs, conditional constructs,
etc... Without knowing how this stuff works first they don't stand much of
a chance when they want to add a new feature to this address book they
built. I find that once a beginner starts seeing results are they
immediately excited and once they see their code break they are instantly
discouraged.

To be more helpful I propose we revamp the tutorial to explain real world
concepts that apply to learning things like string syntax, operator
precedence, recursion, variable scope, and handling things like building a
dynamic ordered/unordered list in HTML using a foreach loop (which is a
pretty common beginner problem). Applying these fundamental concepts of
writing structured code in real life scenarios is going to be far more
beneficial to a beginner than learning HTML/CSS (in my own very modest
opinion).

With that said I'm not opposed to adding multiple tutorials to cover such
subjects as how to build an address book or TODO list, etc...

Sherif,
The one who sometimes wonders where the time went.


Re: [PHP-DOC] AMQP Documentation Update to public docs

2012-12-14 Thread Sherif Ramadan
On Fri, Dec 14, 2012 at 11:54 PM, Pieter de Zwart wrote:

> I don't see AMQPQueue::declareQueue or AMQPExchange::declareExchange. I
> have asked someone else to check their local mirror, and they also do not
> see the changes. I probably screwed up an ref entry somewhere. I'll look
> around, but any hints would be appreciated.
>
> Thanks!
>
>
> On Tue, Dec 11, 2012 at 9:59 PM, Philip Olson  wrote:
>
>>
>> Hello Pieter,
>>
>> Do you have a specific example that's not online? It seems like the
>> changes are online (at least, the parts I checked). Or maybe a
>> particular mirror didn't update?
>>
>> Regards,
>> Philip
>>
>> On Dec 11, 2012, at 9:38 PM, Pieter de Zwart wrote:
>>
>> > Hey guys,
>> >
>> > On Dec 4th, I made the below commit to trunk. I was under the previous
>> > impression that commits made would get rolled up every Friday into the
>> > public docs and pushed out. I, however, do not see the changes below in
>> the
>> > public PHP docs. Has the process changed per chance or did I screw
>> > something up?
>> >
>> > Thanks!
>> > Pieter
>> >
>> >
>> >
>> > 
>> > r328670 | pdezwart | 2012-12-04 20:31:42 -0800 (Tue, 04 Dec 2012) | 4
>> lines
>> > Changed paths:
>> >   M /phpdoc/en/trunk/reference/amqp/amqpconnection/getport.xml
>> >   A /phpdoc/en/trunk/reference/amqp/amqpconnection/gettimeout.xml
>> >   A /phpdoc/en/trunk/reference/amqp/amqpconnection/settimeout.xml
>> >   D /phpdoc/en/trunk/reference/amqp/amqpexchange/declare.xml
>> >   A /phpdoc/en/trunk/reference/amqp/amqpexchange/declareexchange.xml
>> (from
>> > /phpdoc/en/trunk/reference/amqp/amqpexchange/declare.xml:328606)
>> >   D /phpdoc/en/trunk/reference/amqp/amqpqueue/declare.xml
>> >   A /phpdoc/en/trunk/reference/amqp/amqpqueue/declarequeue.xml (from
>> > /phpdoc/en/trunk/reference/amqp/amqpqueue/declare.xml:328606)
>> >
>> > Updating AMQP documentation
>> > * Replacing deprecated declare functions
>> > * Adding missing timeouts
>>
>>
>

Line 13 of en/reference/amqp/amqpqueue/declarequeue.xml:

public
intAMQPQueue::declare

You declared the methodname as AMQPQUeue::declare there. So it shows up as
such.

refname is also there on line 6:

AMQPQueue::declare

Did you mean to change that to AMQPQueue::declareQueue? Same thing I see
with AMQPExchange.


Re: [PHP-DOC] AMQP Documentation Update to public docs

2012-12-11 Thread Sherif Ramadan
On Wed, Dec 12, 2012 at 12:38 AM, Pieter de Zwart wrote:

> Hey guys,
>
> On Dec 4th, I made the below commit to trunk. I was under the previous
> impression that commits made would get rolled up every Friday into the
> public docs and pushed out. I, however, do not see the changes below in the
> public PHP docs. Has the process changed per chance or did I screw
> something up?
>
> Thanks!
> Pieter
>
>
>
> 
> r328670 | pdezwart | 2012-12-04 20:31:42 -0800 (Tue, 04 Dec 2012) | 4 lines
> Changed paths:
>M /phpdoc/en/trunk/reference/amqp/amqpconnection/getport.xml
>A /phpdoc/en/trunk/reference/amqp/amqpconnection/gettimeout.xml
>A /phpdoc/en/trunk/reference/amqp/amqpconnection/settimeout.xml
>D /phpdoc/en/trunk/reference/amqp/amqpexchange/declare.xml
>A /phpdoc/en/trunk/reference/amqp/amqpexchange/declareexchange.xml
> (from /phpdoc/en/trunk/reference/amqp/amqpexchange/declare.xml:328606)
>D /phpdoc/en/trunk/reference/amqp/amqpqueue/declare.xml
>A /phpdoc/en/trunk/reference/amqp/amqpqueue/declarequeue.xml (from
> /phpdoc/en/trunk/reference/amqp/amqpqueue/declare.xml:328606)
>
> Updating AMQP documentation
> * Replacing deprecated declare functions
> * Adding missing timeouts
>
>
>

I see your changes went through fine.


This was an update to the function description which shows up for me on the
mirrors.
/phpdoc/en/trunk/reference/amqp/amqpconnection/getport.xml
http://svn.php.net/viewvc/phpdoc/en/trunk/reference/amqp/amqpconnection/getport.xml?r1=323281&r2=328670

These two were just a change to the revision tags (no content changed on
the page)
/phpdoc/en/trunk/reference/amqp/amqpconnection/gettimeout.xml
/phpdoc/en/trunk/reference/amqp/amqpconnection/settimeout.xml
http://svn.php.net/viewvc/phpdoc/en/trunk/reference/amqp/amqpconnection/gettimeout.xml?r1=328670&r2=328687
http://svn.php.net/viewvc/phpdoc/en/trunk/reference/amqp/amqpconnection/settimeout.xml?r1=328670&r2=328687

These files were deleted
/phpdoc/en/trunk/reference/amqp/amqpexchange/declare.xml
/phpdoc/en/trunk/reference/amqp/amqpqueue/declare.xml
http://svn.php.net/viewvc?view=revision&revision=328670

These were added
/phpdoc/en/trunk/reference/amqp/amqpexchange/declareexchange.xml
/phpdoc/en/trunk/reference/amqp/amqpqueue/declarequeue.xml
http://svn.php.net/viewvc?view=revision&revision=328670

What did you find missing or on which mirror was it not up?

I checked the mirror list they all appear to have updated fine.


Re: [PHP-DOC] how to review or commit PHP TW Documentation

2012-10-08 Thread Sherif Ramadan
On Mon, Oct 8, 2012 at 11:25 PM, ㄚ琪 <2noteb...@yahoo.com.tw> wrote:
> Hello PHP TW Documentation team,
>
> I have translated pecl.xml on php docbook online editor with fb account. But
> I do not know how to review or commit. Could someone help me?
>
> best regards
> Stephen


You have to log in with your SVN account in order to review or commit
changes. If you do not have one simply submit your patch and wait for
someone with an SVN account to review it.


Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-10-04 Thread Sherif Ramadan
On Thu, Sep 27, 2012 at 8:02 PM, Justin  wrote:
> When is this slated for production release?
>


I'm not sure, but the code is pretty much ready to go into production
as of now. Someone just needs to make a final review and approve the
commit. :)

The web-php code can be found here: https://github.com/php/web-php/pull/7

and the web-master code is available here:
https://github.com/srgoogleguy/web-master/commit/7f7b9394f5f11d3b5b5fd039a578aa4e6e40ea16

cheers


Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-16 Thread Sherif Ramadan
On Sun, Sep 16, 2012 at 3:37 AM, Maciek Sokolewicz
 wrote:
> On 12-09-2012 03:54, Sherif Ramadan wrote:
>>
>> Just an update I've pushed the new commits to github and fixed a
>> couple of issues in the backend scripts (patch attached here). The
>> javascript for the user notes stuff was moved to a separate file,
>> it'll be better for caching in the UA this way, and removes a lot of
>> the inline code from the PHP. I also fixed some of the CSS issues with
>> the ?beta=1 version of the site. Although the JS is bit quirky there
>> atm. Working on that, but that's really due to the way the CSS is done
>> there. Still needs tweaking (but it's not like we advertise that part
>> as working now anyway).
>>
>> https://github.com/php/web-php/pull/7
>>
>> If anyone finds any other issues I missed please let me know.
>>
>> Thanks :)
>>
>
> It might not be advertised as working, but it's still used by a lot of
> people (mainly those involved in the PHP Project somehow!) so if you can
> choose not to break it in the first place: just don't break it! ;)
>

This doesn't break anything in the ?beta version of the site actually.
There are just some unintended UI issues due to the way the CSS
styling is done in the beta site right now and that conflicts with my
existing code. It's not that it doesn't work it's just that it can
cause some undesired UX issues in some browsers, mainly that the popup
window will show up in the wrong place on the page.

With that said I can easily turn off the javascript in the beta part
of the site and all the functionality would work as intended without
consequence. In the meant time with or without the javascript this
doesn't break any of the existing code.

> As for the additions to the system; I've finally had some time to review
> what you've added and I think it looks ok. Personally there are only 2 small
> things I'd change in the interface:
> 1. Don't have the popup window "slide" out, I hate that animation (but
> that's a personal thing I guess). Just have it pop up, that's more than
> enough; there's no reason to have to wait till it finishes appearing once
> clicked (and yes, I do know it's pretty fast. Like I said, it's a personal
> thing).
> 2. Change the input field for the reason why a note is reported from input
> to textarea. Many people often like to give more than 2 words of reasoning.
> Even if they only want to explain it in 2 words, they then still can. But it
> makes it easier to read.
>

I intentionally didn't use a textare in the hopes that it might deter
people from writing endless jibber jabber about who knows what that
might not be of any real consequence. My intention was to encourage
short descriptive headings one could read to get an idea of what needs
looked at in the note. My feeling is that less is more here. I might
be wrong, but I have a good compromise here. I can use javascript to
to expand the size of the textbox to a multiline textarea once the
user has typed beyond the viewspace of the input field. :)

> Other than that, I like the interface. I also the think the whole idea is
> ok. Not too sure of the usefulness of voting down and reporting at the same
> time, as Magnus also mentioned, but I guess we could have a pilot for that
> of a kind. Keep it for say 6 months and see if it has any (positive) effect.
> If it doesn't, we can remove it; otherwise we'll know it's good.
>
> - Tul


Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-11 Thread Sherif Ramadan
Just an update I've pushed the new commits to github and fixed a
couple of issues in the backend scripts (patch attached here). The
javascript for the user notes stuff was moved to a separate file,
it'll be better for caching in the UA this way, and removes a lot of
the inline code from the PHP. I also fixed some of the CSS issues with
the ?beta=1 version of the site. Although the JS is bit quirky there
atm. Working on that, but that's really due to the way the CSS is done
there. Still needs tweaking (but it's not like we advertise that part
as working now anyway).

https://github.com/php/web-php/pull/7

If anyone finds any other issues I missed please let me know.

Thanks :)
From ec9e2b8ba7ab5ceacdc8bc482a5c998baaa3a7da Mon Sep 17 00:00:00 2001
From: Sherif Ramadan 
Date: Tue, 11 Sep 2012 21:36:04 -0400
Subject: [PATCH] Updated backend scripts and SQL schema for new user notes
 features.

---
 entry/user-notes-flag.php |  145 +
 entry/user-notes-vote.php |  105 
 fetch/user-notes.php  |   11 +++-
 note.sql  |   30 +
 4 files changed, 289 insertions(+), 2 deletions(-)
 create mode 100644 entry/user-notes-flag.php
 create mode 100644 entry/user-notes-vote.php

diff --git a/entry/user-notes-flag.php b/entry/user-notes-flag.php
new file mode 100644
index 000..28ba00d
--- /dev/null
+++ b/entry/user-notes-flag.php
@@ -0,0 +1,145 @@
+= (NOW() - INTERVAL 1 DAY) AND note_id = '$id'";
+  // Limit 5 flag per note, per host ip, per minute
+  $host_query = "SELECT COUNT(*) AS num FROM flags WHERE hostip = '$hostip' 
AND ts >= (NOW() - INTERVAL 1 MINUTE) AND note_id = '$id'";
+  
+  if (!($result_note = @mysql_query($note_query))) {
+return false;
+  }
+  $rows_note = @mysql_fetch_assoc($result_note);
+  if (empty($rows_note) || $rows_note['num'] == 0 || $rows_note['sect'] !== 
$_POST['sect']) {
+return false;
+  }
+  $sect = $rows_note['sect'];
+  $note_id = $rows_note['id'];
+  
+  
+  if (!($result_client = @mysql_query($client_query))) {
+return false;
+  }
+  $rows_client = @mysql_fetch_assoc($result_client);
+  if (empty($rows_client) || $rows_client['num'] >= 1) {
+return false;
+  }
+  
+  if (!($result_host = @mysql_query($host_query))) {
+return false;
+  }
+  $rows_host = @mysql_fetch_assoc($result_host);
+  if (empty($rows_host) || $rows_host['num'] >= 5) {
+return false;
+  }
+  
+  $flag = mysql_real_escape_string($_POST['flag']);
+  $email = mysql_real_escape_string($_POST['email']);
+  $info = mysql_real_escape_string($_POST['info']);
+  $ts = mysql_real_escape_string(date("Y-m-d H:i:s"));
+  $insert_query = "INSERT INTO flags(note_id,ip,hostip,ts,flag,email,info) 
VALUES('$id','$ip','$hostip','$ts','$flag','$email','$info')";
+  if (!($result = @mysql_query($insert_query))) {
+mail ($failto,
+ 'failed manual note flag query',
+ "Query failed: $insert_query\nError: ".mysql_error(),
+ 'From: php-webmas...@lists.php.net',
+ '-fnore...@php.net'
+);
+return false;
+  }
+  
+  $flag_id = mysql_insert_id();
+  if (!($user = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL))) {
+$user = filter_input(INPUT_POST, "email", FILTER_SANITIZE_STRIPPED, 
FILTER_FLAG_STRIP_HIGH);
+$user = str_replace(array("\r", "\n", " "), "", $user);
+if (!strlen($user)) $user = "Anonymous";
+  }
+  $msg = <<http://www.php.net/{$sect}#{$note_id}
+
+
+Note ID:   $note_id
+Flag ID:   $flag_id
+Section:   $sect
+Email: $user
+Client IP: {$_POST['ip']}
+Host IP:   {$_SERVER['REMOTE_ADDR']}
+Reason:{$_POST['flag']}
+Comment:   {$_POST['info']}
+
+EMAIL_MSG;
+  mail($mailto,"note $note_id flagged in section '$sect'",$msg,"From: 
$user\r\nMessage-ID: ", "-fnore...@php.net");
+
+  return true;
+}
+
+// Initialize Global vars
+$flags = array(
+  "Spam", 
+  "Offensive or abusive language",
+  "This should be a bug report",
+  "Note on wrong/unrelated page",
+  "Invalid or harmful code",
+  "Duplicate note",
+  "This is my note and I want it deleted",
+  "Other",
+);
+
+// Validate the request
+if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+if (empty($_POST['noteid']) || empty($_POST['sect']) || empty($_POST['flag']) 
|| !isset($_PO

Re: [PHP-DOC] Re: [PHP-WEBMASTER] Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-10 Thread Sherif Ramadan
On Mon, Sep 10, 2012 at 1:27 PM, Daniel Brown  wrote:
> On Mon, Sep 10, 2012 at 2:32 AM, Sherif Ramadan  
> wrote:
>>
>> So far that's two people that have expressed a concern against the
>> feature. I seem to be the only one that thinks it's a good idea.
>> Everybody else is indifferent or hasn't voiced their opinion on the
>> matter. While two against one is large in ratio I believe the sample
>> size is incredibly small and thus the possibility of error is likely
>> to be high. Clearly, I'm in the minority.
>
> I'm not generally for the introduction of new features that change
> the fundamental operation of the site, for a variety of reasons: not
> least of which is the lack of maintenance on the code driving the
> features, as well as the basic lack of actual necessity.  This is one
> of the rare cases where I see it not only as useful, but also as a
> smart step in the right direction.  Lately folks have been stepping up
> and taking interest in notes management, but who's to say it'll
> continue as a trend.  I know that, for myself, having spent the last
> few years working to clean up the notes portion of the site, it
> becomes very tedious very quickly.  After somewhere around forty-one
> million, nine-hundred-sixty-two, seven-hundred-fifty-eight notes
> moderated, I believe, is where I noticed that.
>
> So as long as you want to run lead on it, Sherif, and it's
> something we can easily disable entirely, should some unforeseen
> consequences arise as a result of the new voting/reporting features,
> then you can count me in for a plus-one.
>

I have no problem taking lead on it. I'm in it for the long-run and
hopefully looking forward to finding even better ways to improve
notes. My thinking was that if voting/flagging seems to generate
something useful or in some way helps improve user notes that maybe it
would open the doors to adding tagging, threading, or user
authentication which are all things I've heard people voice a need for
in the past. Of course as was discussed with me on IRC, trying to do
too much usually ends up in getting nothing done. So I figured I'd
stick to a few small changes and see how it goes.

Cheers! :)

> --
> 
> Network Infrastructure Manager
> http://www.php.net/


Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-10 Thread Sherif Ramadan
On Mon, Sep 10, 2012 at 10:30 AM, Daniel Convissor
 wrote:
> Hi Sherif:
>
> I like the idea of flagging a comment.  Voting down can take too long to
> produce results.  Particularly if a lousy note is way down on the bottom
> (chronologically or vote wise) of a page with a lot of comments, so few
> people get that far to add their additional down vote.
>
> I haven't looked at your UI, but someone mentioned it being complicated.
> It seems all that's needed is an input box for peple to explain why the
> item is problematic.
>

I'm note sure what is complicated about the interface. I tried to
simplify it as much as possible by providing the lowest possible
bar-to-entry. For example, you don't have to leave the page to flag a
user note if you have javascript enabled. You get a specific set of
choices to select a reason for why you feel the note should be flagged
(including an optional field for any additional explanation you'd like
to offer or even an email address to be contacted). I felt that the
reasons offered were generic enough to fit any of the categorical
reasons a user might have for wanting to report a note to a moderator.
The UI also degrades gracefully from its javascript component and
links to a page where you see the note you're flagging, can fill in
all the necessary information (which is really just a single required
field provided as a drop-down combo-box -- it doesn't get any simpler
than that), and then be directed back to the page you came from.

You can see demonstration of the features I put up at
http://php.sheriframadan.com/manual/en/function.strstr.php#107588 to
get an idea. If there are any suggestions for improving that I'd be
happy to take them into consideration. It's a work-in-progress after
all :)

I don't think that what was meant was that the UI itself is
complicated, but that offering multiple options for what is seemingly
serving the same ultimate purpose (deciding on what notes are, or are
not, useful). That's probably not an invalid argument, in all
fairness. I just happen to be arguing that there's justification for
both. :)

> Thanks,
>
> --Dan
>
> --
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
> data intensive web and database programming
> http://www.AnalysisAndSolutions.com/
> 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335


[PHP-DOC] Re: [PHP-WEBMASTER] Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
Sorry, forgot to reply to all...



So far that's two people that have expressed a concern against the
feature. I seem to be the only one that thinks it's a good idea.
Everybody else is indifferent or hasn't voiced their opinion on the
matter. While two against one is large in ratio I believe the sample
size is incredibly small and thus the possibility of error is likely
to be high. Clearly, I'm in the minority.

However, here's a more objective outlook on the status quo. On one
hand we have user notes that has been around for as long as the manual
has been around. On the other hand we have virtually zero new features
that have been introduced to user notes, save a handful of minor
improvements. That means the only action taken so far has either been
inaction or opposition. By introducing new features we open up the
possibility for gaining a better user experience as well as
introducing more maintenance opportunities. For this I have no doubt
maintenance can become an issue.

I don't see anyone else stepping up to offer more help in this area so
I guess no one is really interested or motivated enough about this
feature. I believe I've demonstrated, at least to some small degree,
however, that I am interested and committed. It'll be really easy to
just drop that one feature and stick with voting. The code is already
written and tested. So the hard part is already done. My emphasis,
though is on showing people that the PHP project can and does still
put in effort to introduce new small changes where possible and that
can have -- if nothing else -- an inspirational effect on others to
either take part in these changes or simply remain indifferent. Either
way we only stand to gain something since people are already verily
indifferent about user notes as it is.

I'll be happy to demonstrate my commitment in the long run and keep
working on better ways to improve where possible, but if no one else
expresses a desire for the feature then I'll gladly drop it.

I appreciate and welcome all constructive criticism and I'll take this
as a learning experience :)


Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
Here's the SQL patch.
From dc2413b5ef33ced0fe48cabf1f85129b881d8330 Mon Sep 17 00:00:00 2001
From: Sherif Ramadan 
Date: Sun, 9 Sep 2012 14:19:51 -0400
Subject: [PATCH] Updated SQL schema for new user notes features
 voting/flagging.

---
 note.sql |   30 ++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/note.sql b/note.sql
index bf2fc7d..c7b12d8 100644
--- a/note.sql
+++ b/note.sql
@@ -10,6 +10,8 @@
master.php.net/entry/user-note.php
master.php.net/fetch/user-notes.php
master.php.net/manage/user-notes.php
+   master.php.net/entry/user-notes-vote.php
+   master.php.net/entry/user-notes-flag.php
 */
 
 CREATE TABLE IF NOT EXISTS note (
@@ -32,3 +34,31 @@ CREATE TABLE IF NOT EXISTS alerts (
   sect VARCHAR(80) not NULL default '',
   updated TIMESTAMP(14) NOT NULL
 ) TYPE=MyISAM;
+
+-- New votes table added by Sherif
+CREATE TABLE IF NOT EXISTS `votes` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `note_id` mediumint(9) NOT NULL,
+  `ip` bigint(20) unsigned NOT NULL DEFAULT '0',
+  `hostip` bigint(20) unsigned NOT NULL DEFAULT '0',
+  `ts` datetime NOT NULL DEFAULT '-00-00 00:00:00',
+  `vote` tinyint(1) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`id`),
+  KEY `note_id` (`note_id`,`ip`,`vote`),
+  KEY `hostip` (`hostip`)
+) TYPE=MyISAM AUTO_INCREMENT=1;
+
+-- New flags table added by Sherif
+CREATE TABLE IF NOT EXISTS `flags` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `note_id` mediumint(9) NOT NULL,
+  `ip` bigint(20) unsigned NOT NULL DEFAULT '0',
+  `hostip` bigint(20) unsigned NOT NULL DEFAULT '0',
+  `ts` datetime NOT NULL DEFAULT '-00-00 00:00:00',
+  `flag` varchar(80) NOT NULL DEFAULT '',
+  `email` varchar(120) NOT NULL DEFAULT '',
+  `info` text,
+  PRIMARY KEY (`id`),
+  KEY `note_id` (`note_id`,`ip`,`flag`),
+  KEY `hostip` (`hostip`)
+) TYPE=MyISAM AUTO_INCREMENT=1;
-- 
1.7.5.4



Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
update
From c8b627002c58899bf88286e140aeb2264aa83117 Mon Sep 17 00:00:00 2001
From: Sherif Ramadan 
Date: Sun, 9 Sep 2012 14:07:01 -0400
Subject: [PATCH] Updated backend scripts for user notes voting/flagging.

---
 entry/user-notes-flag.php |  142 +
 entry/user-notes-vote.php |  105 +
 fetch/user-notes.php  |   11 +++-
 3 files changed, 256 insertions(+), 2 deletions(-)
 create mode 100644 entry/user-notes-flag.php
 create mode 100644 entry/user-notes-vote.php

diff --git a/entry/user-notes-flag.php b/entry/user-notes-flag.php
new file mode 100644
index 000..e7c2373
--- /dev/null
+++ b/entry/user-notes-flag.php
@@ -0,0 +1,142 @@
+= (NOW() - INTERVAL 1 DAY) AND note_id = '$id'";
+  // Limit 5 flag per note, per host ip, per minute
+  $host_query = "SELECT COUNT(*) AS num FROM flags WHERE hostip = '$hostip' 
AND ts >= (NOW() - INTERVAL 1 MINUTE) AND note_id = '$id'";
+  
+  if (!($result_note = @mysql_query($note_query))) {
+return false;
+  }
+  $rows_note = @mysql_fetch_assoc($result_note);
+  if (empty($rows_note) || $rows_note['num'] == 0 || $rows_note['sect'] !== 
$_POST['sect']) {
+return false;
+  }
+  $sect = $rows_note['sect'];
+  $note_id = $rows_note['id'];
+  
+  
+  if (!($result_client = @mysql_query($client_query))) {
+return false;
+  }
+  $rows_client = @mysql_fetch_assoc($result_client);
+  if (empty($rows_client) || $rows_client['num'] >= 1) {
+return false;
+  }
+  
+  if (!($result_host = @mysql_query($host_query))) {
+return false;
+  }
+  $rows_host = @mysql_fetch_assoc($result_host);
+  if (empty($rows_host) || $rows_host['num'] >= 5) {
+return false;
+  }
+  
+  $flag = mysql_real_escape_string($_POST['flag']);
+  $email = mysql_real_escape_string($_POST['email']);
+  $info = mysql_real_escape_string($_POST['info']);
+  $ts = mysql_real_escape_string(date("Y-m-d H:i:s"));
+  $insert_query = "INSERT INTO flags(note_id,ip,hostip,ts,flag,email,info) 
VALUES('$id','$ip','$hostip','$ts','$flag','$email','$info')";
+  if (!($result = @mysql_query($insert_query))) {
+mail ($failto,
+ 'failed manual note flag query',
+ "Query failed: $insert_query\nError: ".mysql_error(),
+ 'From: php-webmas...@lists.php.net',
+ '-fnore...@php.net'
+);
+return false;
+  }
+  
+  $flag_id = mysql_insert_id();
+  if (!($user = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL))) {
+$user = filter_input(INPUT_POST, "email", FILTER_SANITIZE_STRIPPED, 
FILTER_FLAG_STRIP_HIGH);
+$user = str_replace(array("\r", "\n"), "", $user);
+  }
+  $msg = <<", "-fnore...@php.net");
+
+  return true;
+}
+
+// Initialize Global vars
+$flags = array(
+  "Spam", 
+  "Offensive or abusive language",
+  "This should be a bug report",
+  "Note on wrong/unrelated page",
+  "Invalid or harmful code",
+  "Duplicate note",
+  "This is my note and I want it deleted",
+  "Other",
+);
+
+// Validate the request
+if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+if (empty($_POST['noteid']) || empty($_POST['sect']) || empty($_POST['flag']) 
|| !isset($_POST['email']) ||
+  !isset($_POST['info']) || !isset($_POST['ip'])) {
+header("HTTP/1.0 400", true);
+exit();
+}
+if (!in_array($_POST['flag'],$flags, true)) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+// Check master DB for hostip and clientip limits
+if (!db_flag_note()) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+header("HTTP/1.0 200",true);
+echo 1;
diff --git a/entry/user-notes-vote.php b/entry/user-notes-vote.php
new file mode 100644
index 000..3ec68b9
--- /dev/null
+++ b/entry/user-notes-vote.php
@@ -0,0 +1,105 @@
+= (NOW() - INTERVAL 1 DAY) AND note_id = '$id'";
+  // Limit 5 votes per note, per host ip, per minute
+  $host_query = "SELECT COUNT(*) AS num FROM votes WHERE hostip = '$hostip' 
AND ts >= (NOW() - INTERVAL 1 MINUTE) AND note_id = '$id'";
+
+  if (!($result_note = @mysql_query($note_query))) {
+return false;
+  }
+  $rows_note = @mysql_fetch_assoc($result_note);
+  if (empty($rows_note) || $rows_note['num'] == 0) {
+return false;
+  }
+  // Check that the note is in the right section
+  if ($rows_note['sect'] !== $_POST['sect']) {
+return false;
+  }
+  
+  if (!($result_clien

Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
Sorry, here's the patch as an attachment.
From 362719eb0aaefb323e05a15ddcd2077e84b18fee Mon Sep 17 00:00:00 2001
From: Sherif Ramadan 
Date: Sun, 9 Sep 2012 13:31:36 -0400
Subject: [PATCH] Updated backend scripts for user notes voting/flagging.

---
 entry/user-notes-flag.php |  160 +
 entry/user-notes-vote.php |  105 +
 fetch/user-notes.php  |   13 +++-
 3 files changed, 275 insertions(+), 3 deletions(-)
 create mode 100644 entry/user-notes-flag.php
 create mode 100644 entry/user-notes-vote.php

diff --git a/entry/user-notes-flag.php b/entry/user-notes-flag.php
new file mode 100644
index 000..84eac24
--- /dev/null
+++ b/entry/user-notes-flag.php
@@ -0,0 +1,160 @@
+= (NOW() - INTERVAL 1 DAY) AND note_id = '$id'";
+  // Limit 5 flag per note, per host ip, per minute
+  $host_query = "SELECT COUNT(*) AS num FROM flags WHERE hostip = '$hostip' 
AND ts >= (NOW() - INTERVAL 1 MINUTE) AND note_id = '$id'";
+  
+  if (!($result_note = @mysql_query($note_query))) {
+return false;
+  }
+  $rows_note = @mysql_fetch_assoc($result_note);
+  if (empty($rows_note) || $rows_note['num'] == 0 || $rows_note['sect'] !== 
$_POST['sect']) {
+return false;
+  }
+  $sect = $rows_note['sect'];
+  $note_id = $rows_note['id'];
+  
+  
+  if (!($result_client = @mysql_query($client_query))) {
+return false;
+  }
+  $rows_client = @mysql_fetch_assoc($result_client);
+  if (empty($rows_client) || $rows_client['num'] >= 1) {
+return false;
+  }
+  
+  if (!($result_host = @mysql_query($host_query))) {
+return false;
+  }
+  $rows_host = @mysql_fetch_assoc($result_host);
+  if (empty($rows_host) || $rows_host['num'] >= 5) {
+return false;
+  }
+  
+  $flag = mysql_real_escape_string($_POST['flag']);
+  $email = mysql_real_escape_string($_POST['email']);
+  $info = mysql_real_escape_string($_POST['info']);
+  $ts = mysql_real_escape_string(date("Y-m-d H:i:s"));
+  $insert_query = "INSERT INTO flags(note_id,ip,hostip,ts,flag,email,info) 
VALUES('$id','$ip','$hostip','$ts','$flag','$email','$info')";
+  if (!($result = @mysql_query($insert_query))) {
+mail ($failto,
+ 'failed manual note flag query',
+ "Query failed: $insert_query\nError: ".mysql_error(),
+ 'From: php-webmas...@lists.php.net',
+ '-fnore...@php.net'
+);
+return false;
+  }
+  
+  $flag_id = mysql_insert_id();
+  if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
+$user = filter_var($_POST['email'], FILTER_SANITIZE_STRIPPED, 
FILTER_FLAG_STRIP_HIGH);
+$user = str_replace(array("\r", "\n"), "", $user);
+  }
+  else {
+$user = $_POST['email'];
+  }
+  $msg = <<", "-fnore...@php.net");
+
+  return true;
+}
+
+// Send email for flagged note
+function email_flag() {
+  return true;
+}
+
+// Initialize Global vars
+$flags = array(
+  "Spam", 
+  "Offensive or abusive language",
+  "This should be a bug report",
+  "Note on wrong/unrelated page",
+  "Invalid or harmful code",
+  "Duplicate note",
+  "This is my note and I want it deleted",
+  "Other",
+);
+
+// Validate the request
+if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+if (empty($_POST['noteid']) || empty($_POST['sect']) || empty($_POST['flag']) 
|| !isset($_POST['email']) ||
+  !isset($_POST['info']) || !isset($_POST['ip'])) {
+header("HTTP/1.0 400", true);
+exit();
+}
+if (!in_array($_POST['flag'],$flags, true)) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+// Check master DB for hostip and clientip limits
+if (!db_check()) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+if (!email_flag()) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+header("HTTP/1.0 200",true);
+echo 1;
diff --git a/entry/user-notes-vote.php b/entry/user-notes-vote.php
new file mode 100644
index 000..dc6c58b
--- /dev/null
+++ b/entry/user-notes-vote.php
@@ -0,0 +1,105 @@
+= (NOW() - INTERVAL 1 DAY) AND note_id = '$id'";
+  // Limit 5 votes per note, per host ip, per minute
+  $host_query = "SELECT COUNT(*) AS num FROM votes WHERE hostip = '$hostip' 
AND ts >= (NOW() - INTERVAL 1 MINUTE) AND note_id = '$id'";
+
+  if (!($result_note = @mysql_query($note_query))) {
+return false;
+  }
+  $rows_note = @mysql_fetch_assoc($result_note);
+  if (empty($rows_note) || $rows_note

Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
>From 362719eb0aaefb323e05a15ddcd2077e84b18fee Mon Sep 17 00:00:00 2001
From: Sherif Ramadan 
Date: Sun, 9 Sep 2012 13:31:36 -0400
Subject: [PATCH] Updated backend scripts for user notes voting/flagging.

---
 entry/user-notes-flag.php |  160 +
 entry/user-notes-vote.php |  105 +
 fetch/user-notes.php  |   13 +++-
 3 files changed, 275 insertions(+), 3 deletions(-)
 create mode 100644 entry/user-notes-flag.php
 create mode 100644 entry/user-notes-vote.php

diff --git a/entry/user-notes-flag.php b/entry/user-notes-flag.php
new file mode 100644
index 000..84eac24
--- /dev/null
+++ b/entry/user-notes-flag.php
@@ -0,0 +1,160 @@
+= (NOW() - INTERVAL 1 DAY) AND note_id = '$id'";
+  // Limit 5 flag per note, per host ip, per minute
+  $host_query = "SELECT COUNT(*) AS num FROM flags WHERE hostip =
'$hostip' AND ts >= (NOW() - INTERVAL 1 MINUTE) AND note_id = '$id'";
+
+  if (!($result_note = @mysql_query($note_query))) {
+return false;
+  }
+  $rows_note = @mysql_fetch_assoc($result_note);
+  if (empty($rows_note) || $rows_note['num'] == 0 ||
$rows_note['sect'] !== $_POST['sect']) {
+return false;
+  }
+  $sect = $rows_note['sect'];
+  $note_id = $rows_note['id'];
+
+
+  if (!($result_client = @mysql_query($client_query))) {
+return false;
+  }
+  $rows_client = @mysql_fetch_assoc($result_client);
+  if (empty($rows_client) || $rows_client['num'] >= 1) {
+return false;
+  }
+
+  if (!($result_host = @mysql_query($host_query))) {
+return false;
+  }
+  $rows_host = @mysql_fetch_assoc($result_host);
+  if (empty($rows_host) || $rows_host['num'] >= 5) {
+return false;
+  }
+
+  $flag = mysql_real_escape_string($_POST['flag']);
+  $email = mysql_real_escape_string($_POST['email']);
+  $info = mysql_real_escape_string($_POST['info']);
+  $ts = mysql_real_escape_string(date("Y-m-d H:i:s"));
+  $insert_query = "INSERT INTO
flags(note_id,ip,hostip,ts,flag,email,info)
VALUES('$id','$ip','$hostip','$ts','$flag','$email','$info')";
+  if (!($result = @mysql_query($insert_query))) {
+mail ($failto,
+ 'failed manual note flag query',
+ "Query failed: $insert_query\nError: ".mysql_error(),
+ 'From: php-webmas...@lists.php.net',
+ '-fnore...@php.net'
+);
+return false;
+  }
+
+  $flag_id = mysql_insert_id();
+  if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
+$user = filter_var($_POST['email'], FILTER_SANITIZE_STRIPPED,
FILTER_FLAG_STRIP_HIGH);
+$user = str_replace(array("\r", "\n"), "", $user);
+  }
+  else {
+$user = $_POST['email'];
+  }
+  $msg = <<", "-fnore...@php.net");
+
+  return true;
+}
+
+// Send email for flagged note
+function email_flag() {
+  return true;
+}
+
+// Initialize Global vars
+$flags = array(
+  "Spam",
+  "Offensive or abusive language",
+  "This should be a bug report",
+  "Note on wrong/unrelated page",
+  "Invalid or harmful code",
+  "Duplicate note",
+  "This is my note and I want it deleted",
+  "Other",
+);
+
+// Validate the request
+if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+if (empty($_POST['noteid']) || empty($_POST['sect']) ||
empty($_POST['flag']) || !isset($_POST['email']) ||
+  !isset($_POST['info']) || !isset($_POST['ip'])) {
+header("HTTP/1.0 400", true);
+exit();
+}
+if (!in_array($_POST['flag'],$flags, true)) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+// Check master DB for hostip and clientip limits
+if (!db_check()) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+if (!email_flag()) {
+  header("HTTP/1.0 400", true);
+  exit();
+}
+
+header("HTTP/1.0 200",true);
+echo 1;
diff --git a/entry/user-notes-vote.php b/entry/user-notes-vote.php
new file mode 100644
index 000..dc6c58b
--- /dev/null
+++ b/entry/user-notes-vote.php
@@ -0,0 +1,105 @@
+= (NOW() - INTERVAL 1 DAY) AND note_id = '$id'";
+  // Limit 5 votes per note, per host ip, per minute
+  $host_query = "SELECT COUNT(*) AS num FROM votes WHERE hostip =
'$hostip' AND ts >= (NOW() - INTERVAL 1 MINUTE) AND note_id = '$id'";
+
+  if (!($result_note = @mysql_query($note_query))) {
+return false;
+  }
+  $rows_note = @mysql_fetch_assoc($result_note);
+  if (empty($rows_note) || $rows_note['num'] == 0) {
+return fa

Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
On Sun, Sep 9, 2012 at 11:53 AM, Hannes Magnusson
 wrote:
> On Sun, Sep 9, 2012 at 3:00 PM, Sherif Ramadan  
> wrote:
>
>> http://php.sheriframadan.com/manual/en/function.strstr.php#107588 and
>> click on the flag on top of the note. It should be pretty self
>
> This feature looks very odd in ?beta=1 mode..
>
> -Hannes

Yes, the beta just uses different styling. The feature depends on CSS
rules and JS, which was all designed to degrade gracefully in case the
user doesn't have any of that enabled. I just have to update the
stylesheets and it should work just fine in ?beta=1 as well :)

Thanks for catching that.


Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
On Sun, Sep 9, 2012 at 10:13 AM, Hannes Magnusson
 wrote:
>
> Ok. But why then all the different options?
> If a note is flagged, the expected outcome is for an admin to delete
> it - after verifying that the note is broken.
> There isn't any reason for the user to jump through hoops and buttons
> to tell us why, we need to read the note anyway.
> In my mind, that means flagging is another way of "mark as bad note"..
> which effectively is what a note with down votes is too, and the end
> result is the same; note removed.
>
>
> -Hannes

I understand what you're saying and I've been back and forth about
whether or not they're both worthwhile or not. However, I can't find a
compelling reason not to include this additional features. It serves a
slightly different need for the user. The ability to feel like they
communicated their express opinion to a moderator. Whereas voting is
meant to be handled by an autonomous system.

Voting is a quantitative gauge of what the community thinks about the
notes on any particular page of the manual. With pages that have a lot
of notes it might not be worthwhile for the user to have to read
through all of them. Most people like to just browser the top two or
three notes unless they're looking for something specific. This means
it'll be easier to spot which ones the majority of users agree are
useful.

I guess the pace at which notes accumulate in the manual now is pretty
sluggish. Voting might make community interaction quicker, but I of
course we don't know by how much yet. My take on it was that voting
something down might have a slower response time for some pages than
others. Not every page in the manual is frequented often and again I
suspect the desire for some users to feel like they got through to a
human might be needed there.

Of course, my suspicions may be completely wrong. :)


Re: [PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
On Sun, Sep 9, 2012 at 9:52 AM, Hannes Magnusson
 wrote:
>
> I've only quickly scanned through the phpweb code, and it looks fine.
> I'm still not entirely certain of what the flagging a usernote means,
> or how it works in practice.

The flagging features just allows users to notify moderators of any
potential problem that may need human intervention. For example, a
user may have accidentally submitted a note twice and would like to
alert us to get the duplicate removed. Or, a user spots some spam,
offensive language, or a note that should be filed as a bug report
instead.

The feature simply sends an email to php-notes and logs the
information in the database so that anyone with notes karma can take
whatever necessary action. The intention is to cut down on having to
dig for problem notes and let users be able to notify the moderators
directly. It might not get used very often, but I figured providing
users with the option shouldn't hurt. You can see the feature in
action if you go to
http://php.sheriframadan.com/manual/en/function.strstr.php#107588 and
click on the flag on top of the note. It should be pretty self
explanatory from there what actions the user can take and how they
might be helpful.

If it proves useless later on we can always remove or disable it.

>
> As for the up/down voting, I like it.
>
> I don't think we need any login system or complicated security
> infrastructure. We will easily be able to detect if a bad note is
> getting hundreds of votes, and will simply remove that note.
> If a good note is getting all flooded up, so what?
>
> Newest notes have always been at the top, so voting dozens of times on
> a note you just submitted won't give you anything extra.

Well, the general idea I guess was to allow for tighter control. You
could, for example, allow a user to edit their note if you could
authenticate them somehow. If people think it's overkill, no problem.
I was just under the impression this was planned for in the past but
never materialized.

>
> -Hannes


[PHP-DOC] Improving User Notes In The Manual -- First Steps

2012-09-09 Thread Sherif Ramadan
I'm hoping to start a discussion into the next phases of improving
user notes and php.net in general.

So far since the discussion on improving user notes I've implemented a
few improvements including: voting, flagging, and sorting user notes.
For some background on the discussion see
https://wiki.php.net/ideas/usercomments#new_user_notes_features

The code can be found here
https://github.com/srgoogleguy/web-php/commit/320a3db027ceb5ed25dda8da53b2b0f2f316c18d

The limitations of this implementation are that users are still not
held accountable for their contributions whether by submitting new
notes, voting on existing notes, or flagging other users' notes. It's
my understanding that a site-wide authentication system for php.net
was discussed in the past with OAuth 2.0 being a primary candidate.
Offering authentication can help limit both abuse of these new user
notes features and provide incentive for contribution.

Currently the existing code relies on master.php.net to store the IP
address of the client voting on a note and thus allowing us to limit
votes to 1 per note, per IP, per day. Not really the greatest way to
prevent abuse, but it's the only reasonable way I can see to do it
now. The SQL for the new tables that need to go into master can be
found here: http://php.sheriframadan.com/master/master-db.sql.txt

There would need to be two additional scripts added to
master.php.net/entry for voting and flagging, that will handle the
database and email work. Additionally, there needs to be one more
script on master updated, which is the script that generates the note
files populated on the mirrors through rsync. This just appends the
additional vote data onto the end of the note files. The rest is
handled by the mirrors in the commit above.

To next step is to get OAuth 2.0 working so that we can control user
notes contributions more tightly. The problem is this requires a
heavier load on master.php.net which means we have to store tokens in
the master db. Additionally there's the question of how much
work/trust can we put into the mirrors for handling the authentication
process? Do we direct everything to master or should the individual
mirrors be accountable for the authentication? There are some security
concerns there, but I'm not sure what the best approach is. If anyone
is interested in helping out weed these issues and offer any
assistance that'll be great.


Re: [PHP-DOC] [PHP-WEBMASTER] User notes

2012-08-31 Thread Sherif Ramadan
On Fri, Aug 31, 2012 at 12:49 PM, Philip Olson  wrote:
>
> Although the user notes have been discussed many times*, I reckon
> nothing new has been implemented because current ideas either don't
> feel right and/or require too much work. So let's define what user
> notes are for:
>
>   - Original purpose: To find content, and fold it into the manual
>   - Current purpose:  ???
>
> I can only speak for my reasons for using them, which involve two
> main points:
>
>   - Finding examples
>   - Reading about gotchas/workarounds
>
> Why do other people here use user notes? Why do newbies use them? And
> what makes a "good" user note? We each use our gut while determining
> this now let's embrace it.
>
> * https://wiki.php.net/ideas/usercomments
>
> Regards,
> Philip
>


I disagree that the feature is completely useless and that it would be
better to get rid of it entirely.

I agree the current system leaves much to be desired, which is why
when Philip asked me if I'd like to help I agreed. I do see some very
good potential for the contributions in user notes (albeit they are
few and far between). What I find most helpful is that some of these
users can spot things we either missed early on or have simply ignored
for far too long.

I've spent hours sifting through user notes and it's not pretty. I've
deleted quite a few of these harmful/misplaced notes as Adam pointed
out. It's not a desirable task, but that's why I've offered some new
suggestions that can greatly improve what we have rather than just
kill it entirely.

* We need to start bringing more attention to those notes that have
potential. Currently the notes are always listed in descending order
by date of submission. This is completely useless since most people
don't bother to scroll down far enough to find good notes if the first
few dozen notes on the page are completely distasteful. As an example
I spent a couple of hours one night trying removing nearly all of the
top 10 notes on a few pages none of which I could objectively say
provided anything remotely useful (some were even harmful). However,
by the time I scrolled down to the very bottom of the page and had
read through every single note, I realized there were still some gems
there from as far back as 2003 (things I would still consider useful
for anyone to read). Not bringing enough attention to these notes and
focusing just on who submitted the most recent note is clearly a
problem I intend to fix.

* As Rasmus and others have pointed out we have plenty of people with
karma to the notes. Not everyone bothers, but I honestly believe this
to be a fault of the system not the people. We can positively
influence people to help with notes by giving them easy to digest
information that will help them make an intelligent decision. For
example, allowing users to flag notes can help pinpoint which notes
are currently getting flagged the most and bring them to our attention
for either deletion or whatever course of action needs taken.

I should have some time this weekend to start getting some of these
new features into notes and we can test them out. If users take great.
If not I'm all for finding ways to do better.


[PHP-DOC] VCS Account Request: googleguy

2012-07-18 Thread Sherif Ramadan
Hi, I've had a few patches accepted into PHP via git already 
http://github.com/srgoogleguy and I'm going to be working the user 
comments feature for the docs php.net and was advised to apply for a git 
account here.



[PHP-DOC] Requesting SVN Account to Contribute to the PHP Documentation

2011-04-14 Thread Sherif Ramadan
Hi,

My name is Sherif Ramadan and I'm interested in contributing to the PHP
Documentation on php.net as I see there are a lot of undocumented functions
and some that lack good examples based on both personal experience and from
correspondence with fellow PHP coders. I read some information on
doc.php.net and found an FAQ that says to email here in order to get an SVN
account.

My blog can be found at http://sheriframadan.com just to give you a little
background... I've been coding in PHP on and off for about 5 years now. I'm
not very proficient in C, but I love to learn and enjoy contributing to the
PHP community as much as possible. At this point my primary interest is
committing to the PHP documentation and not the PHP source tree. Please let
me know what else is needed to gain an account and hopefully some good Karma
:) Thanks!