[PHP] tempnam() not working as expected...

2012-04-13 Thread tamouse mailing lists
Can someone explain the following to me:




/Users/tamara/Sites/gallery/lib/common/t/dirGuWOLW is  a directory
/private/var/folders/pI/pIx-p0mhH5eEQ64yAiDQmE+++TI/-Tmp-/fileC7Rnzg
is  a directory

Why isn't the second tempnam using the directory path I pass to it?

The strange thing I notice is that if I pass in a directory path to
tempnam that was NOT created initially by tempnam, it works:

miishka:t tamara$ mkdir a
miishka:t tamara$ php -r 'echo
tempnam("/Users/tamara/Sites/gallery/lib/common/t/a","file").PHP_EOL;'
/Users/tamara/Sites/gallery/lib/common/t/a/filepSwRzF
miishka:t tamara$

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



Re: [PHP] case-insensitive $_REQUEST,$_GET,$_POST keys?

2012-04-13 Thread tamouse mailing lists
On Fri, Apr 13, 2012 at 12:22 PM, David OBrien  wrote:
> On Fri, Apr 13, 2012 at 1:13 PM, tamouse mailing lists
>  wrote:
>>
>> Anyone have a quick-and-dirty way to check $_REQUEST keys that is
>> case-insensitive?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> this what you asking?
>
> foreach ( $_REQUEST as $key => $value ) {
>       if ( strtolower($key) in array('name','username','password')) $data[
> strtolower($key) ] = $value;
> }

That would do it! Thanks.

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




Re: [PHP] tempnam() not working as expected...

2012-04-18 Thread tamouse mailing lists
On Mon, Apr 16, 2012 at 3:09 AM, ma...@behnke.biz  wrote:
>> mkdir($d,777,true);                /* make the directory */
> Try using "mkdir($d, 0777, true);"

Herein, my friends, lies the problem. Silly me, using a DECIMAL number
(777) instead of an OCTAL number (0777).

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



Re: [PHP] sms class

2012-04-18 Thread tamouse mailing lists
On Tue, Apr 17, 2012 at 2:08 PM, DZvonko Nikolov  wrote:
> I need a class that sends sms messages to list of numbers.
> I'm quite new to that issue, so I need to know what I need
> more. Thanks in advance.

If this is very low volume, would using email->sms work?

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



Re: [PHP] Re: Email Antispam

2012-04-18 Thread tamouse mailing lists
On Wed, Apr 18, 2012 at 8:47 PM, Ross McKay  wrote:
> On Wed, 18 Apr 2012 11:08:00 -0400, Jim Giner wrote:
>
>>He literally wants the "addresses" visible on the sight?  [...]
>
> Yes, they want the addresses visible and clickable on the website. They
> have contact forms, but they also want the email addresses (of their
> scientists and other consultants) available to their clients. And they
> want the addresses to be shielded against harvesting for spam.

Ob/Deobfuscation schemes that use javascript are a partial solution.
Many spam harvesters are smart enough these days to know enough about
decoding email addresses even obfuscated with javascript, with or
without the mailto: scheme. Any that do obfuscation by substituting
html entities for the characters are quite easily cracked. (Just
appearance of a string of html entities is often enough to indicate
there is something there to decode.) There is no 100% solution here.
Coming up with clever ways to obfuscate the address on download, and
deobfuscate it afterwards to display to the user will work for a
while, however, the people writing spam harvesters are just as clever
as we are. If the application is going to end up with email addresses
displayed on the screen, some spam harvester is going to be able to
get them. Even if you come up with a method that will stop them now,
it won't stop them forever.

> As I said, I don't like doing it this way, but the client gets what they
> want after the options have been explained to them.

They need to understand the options, but even more important, the
risks of any solution, and of the concept as a whole. After you've
presented the risks, and the lack of a 100% solution, if they still
want to do something against their own policies, you have to decide if
your liability in giving it to them is going to be a problem.

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



Fwd: [PHP] sms class

2012-04-19 Thread tamouse mailing lists
> -- Forwarded message --
> From: DZvonko Nikolov 
> Date: Thu, Apr 19, 2012 at 5:10 AM
> Subject: Re: [PHP] sms class
> To: tamouse mailing lists 
>
>
> if this is simple, yes.
>
>
> ---
> Regards
>
> DZvonko Nikolov
>
>
> dzvo...@gmail.com
> dzvo...@yahoo.com
> ---
> The best things are simple,
> but finding these simple things is not simple.
>
>
> Simplicity carried to the extreme becomes elegance.
> -----------
>
> 
> From: tamouse mailing lists 
> To: DZvonko Nikolov 
> Cc: "php-general@lists.php.net" 
> Sent: Thursday, April 19, 2012 7:19 AM
> Subject: Re: [PHP] sms class
>
> On Tue, Apr 17, 2012 at 2:08 PM, DZvonko Nikolov  wrote:
> > I need a class that sends sms messages to list of numbers.
> > I'm quite new to that issue, so I need to know what I need
> > more. Thanks in advance.
>
> If this is very low volume, would using email->sms work?
>
>

(Remember to 1: post back to the list, 2: reply at the bottom)

Look here: https://en.wikipedia.org/wiki/List_of_SMS_gateways

Mailing stuff from php is also dead easy:
http://us2.php.net/manual/en/book.mail.php

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



Re: [PHP] SqLite INSERT want not write

2012-04-19 Thread tamouse mailing lists
Maybe this will make the syntax errors stand out more:

http://dl.dropbox.com/u/571329/Screenshots/Picture%209.png

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



Re: [PHP] SqLite INSERT want not write

2012-04-19 Thread tamouse mailing lists
On Thu, Apr 19, 2012 at 2:17 PM, Steven Staples  wrote:
>> -Original Message-
>> From: Silvio Siefke [mailto:siefke_lis...@web.de]
>> Sent: April 19, 2012 3:11 PM
>> To: php-general@lists.php.net
>> Subject: Re: [PHP] SqLite INSERT want not write
>>
>> On Thu, 19 Apr 2012 14:57:04 -0400
>> "Steven Staples"  wrote:
>>
>> > I think all you had to do was change this line: (line 27 in the
>> > original
>> > paste)
>> > $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content)
>> >       VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title,
>> > :teaser, :content);';
>> >
>> > To this:
>> > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
>> >       VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title,
>> > :teaser, :content);";
>>
>> Thats end with:
>> PDOException: SQLSTATE[HY000]: General error: 1 near "(": syntax error
>>
>> I has changed what say Stuart, no Sytax errors but in the database nothing
>> will write.
>>
>> Regards
>> Silvio
>>
>
> Ok, so I was wrong... ;)   it does happen
>
> Try this:
> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
>       VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title,
>  :teaser, :content);";
>
> Or
> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
>       VALUES (NOW(), :autor, :title, :teaser, :content);";
>
>
> The first example, you don't need the time(), and you had the date format
> wrong...
> The second example, uses the NOW() time, which is the timestamp for sql
>
> Maybe this time I will get it right ;) -- its been a long day, and it is
> only 1/2 done
>
> Steve
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

For sqlite, you can specify the current datetime with just "now".

So perhaps the insert statement could be simplified to:

$sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
VALUES(now, :autor, :title, :teaser, :content);";

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



[PHP] Re: [PHP-DB] School timetable in php

2012-04-22 Thread tamouse mailing lists
On Sun, Apr 22, 2012 at 1:41 AM, Vinay Kannan  wrote:
> Weekly subject wise lecture schedule, subject wise / faculty wise.
>
>
> On Sun, Apr 22, 2012 at 12:02 PM, tamouse mailing lists
>  wrote:
>>
>> On Fri, Apr 20, 2012 at 7:00 AM, Vinay Kannan  wrote:
>> > I am trying to develop a school time table system in php mysql, anybody
>> > has
>> > any headsup on the same, i was thinking about some existing scripts to
>> > take
>> > a look at.
>>
>> Not entirely clear what is meant by "time table" -- do you mean
>> schedule of classes? Important dates in the school year? or...?
>>
>> Also, what is it you want to be able to do with this? Who will be
>> using this? There are many different approaches one can take,
>> depending on what needs to happen. Hard to know what to suggest
>> without a little more info?
>
>

I modified an application that was originally set up for scheduling
conference rooms, my version was to schedule appointments at a
convention. You can grab it at https://github.com/tamouse/cdmacal  .
It is probably *way* more complex than you need, but it might give
some ideas?

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



Re: [PHP] Running through an enormous SQL file

2012-05-04 Thread tamouse mailing lists
On Fri, May 4, 2012 at 6:36 PM, Brian Dunning  wrote:
> I have a script that downloads a 267MB SQL file (it creates and loads a MySQL 
> database). Any idea how to do this? Obviously I'm not going to get a file 
> that size into memory to loop through.

Is there any need to use PHP with this at all? If it's already in SQL,
can't you just feed it to mysql?

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



Re: [PHP] Calculating driving distance between UK postcodes

2012-05-04 Thread tamouse mailing lists
On Fri, May 4, 2012 at 9:18 AM, Terry Ally (Gmail)  wrote:
> Google works in Javascript extensively - not a language with which I
> have in-depth experience hence my reason for asking for PHP solution.
>
> For example the following will get me a JSON output with the distance in
> Kms and time. I don't know how to get PHP to read this information and
> extract just the distance. I need the distance so that I can calculate cost
> of a trip.
>
> http://maps.googleapis.com/maps/api/distancematrix/json"; method="get">
> 
> 
> 
> 
>  onClick="document.getElementById('google').submit()">Get
> Distance
> 

Using Google Maps API is pretty straight-forward. You don't need to
set up a form or a use a POST to get the info. This page should
describes how to use a standard GET query to get the info you want:

< https://developers.google.com/maps/documentation/distancematrix/ >

Setting up the proper URL to call, you can activate it using
file_get_contents provided you have allow_url_fopen set to true in
php.ini. (Do make sure to check for possible errors returned.)

You can get the response back as either JSON or XML, both of which PHP
can parse into useful data structures:

< http://us.php.net/manual/en/function.json-decode.php >

< http://us.php.net/manual/en/book.simplexml.php >

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



Re: [PHP] function

2012-05-04 Thread tamouse mailing lists
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott
 wrote:
> I need to access a FUNCTION I programmed within a different FUNCTION.  Are 
> these able to be passed like a variable?  Or are they able to become like a 
> $_SESSION variable in nature?  How am I able to do this?
>
> I am essentially programming:
>
> ===
> function name( $flag1, $flag2 ) {
>
> # some PHP
>
> echo name_of_a_different_function( $flag1 , $flag2 );
>
> }
> ===
>
> The error I am receiving is “Call to undefined function 
> name_of_a_different_function”

Where is name_of_a_different_function defined? If it is somewhere in
the same file as name, that shouldn't be a problem, provided it is
defined in the same namespace/scope as name. If it is defined in a
different file, you need to include that file before you make the echo
statement.

For example:

function func1 ($flag1, $flag2) {

   # blah blah

   echo func2($flag1, $flag2);
}

function func2 ($flag1, $flag2) {

   #blah blah

   return "some string value";
}

in the same file should be just fine. It doesn't really matter what
order func1 and func2 are declared in.

However, if func2 is defined in some_other_file.php, you need to
include it in this_file.php (where func1 is defined) first:

this_file.php:
include('some_other_file.php');

function func1 ($flag1, $flag2) {

   #blah blah

   echo func2 ($flag1, $flag2);
}


some_other_file.php:
function func2 ($flag1, $flag2) {

   #blah blah

   return "some string value";
}

If func2 is a method for an object/class, you'll have to access it
that way in func1:

this_file.php:
include('MyClass.php');
function func1 ($flag1, $flag2) {

   # blah blah, instantiate object?
   $myobj = new MyClass();

   echo $myobj->func2 ($flag1, $flag2);
}

MyClass.php:
class MyClass
{
   function func2 ($flag1, $flag2) {

  #blah blah
  return "some string value";
   }
}

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



Re: [PHP] PHP & Emacs

2012-05-04 Thread tamouse mailing lists
On Fri, May 4, 2012 at 7:43 AM, Gerardo Benitez
 wrote:
> Hi Mihamina,
>
> I think that a few number of people use Emacs to write Php, in fact for
> proffesionals porpuse the people use a IDE for Php, like Netbeams, Eclipse
> PDT or Zend Studio.
>
> Regards,
> Gerardo
>
> On Wed, May 2, 2012 at 8:21 AM, Mihamina Rakotomandimby
> wrote:
>
>> Hi all,
>>
>> For curiosity, are there people here using Emacs to code in PHP?
>> What modes do you add? cedet, ecb,...
>>
>> I see (just for the example) that Drupal has a short documentation page
>> for Emacs http://drupal.org/node/59868
>>
>> Have you got some in your bookmarks for general PHP coding?
>>
>> --
>> RMA.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Gerardo Benitez
> -
> Programador Web Freelance

I use Emacs for editing practically everything. I use a
[php-mode.el](http://php-mode.sourceforge.net/) that is derived from
cc-mode, and works pretty well (except for one annoyance in that it
doesn't recognize octothorpes (#) for comment beginners :P). [Multiple
Major Modes](http://emacswiki.org/emacs/MultipleModes) is also pretty
helpful so you can edit files that mix PHP, HTML, JS, and CSS (which
is NOT a best practice, but sometimes necessary).

The [Emacs Wiki](http://emacswiki.org) seems to be the best place for
finding things in general, but is still not really as good as just
doing a google/bing/ddg search on what you're looking for. *Lots* of
people write about emacs, and there are generous tidbits all over.

Another thing I use heavily are snippets. The best package I've found
for this is the (Yet Another Snippets
mode)[https://github.com/capitaomorte/yasnippet] which speeds up
development quite a bit.

I have a (very limited) info page on Emacs on my wiki:
http://wiki.tamaratemple.com/Technology/Emacs (this is not
advertising; my server is small and won't handle a huge number of
hits; please don't /. it!)

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



Re: [PHP] Retrieve pages from an ASP driven site

2012-05-04 Thread tamouse mailing lists
On Wed, May 2, 2012 at 11:37 PM, EPA WC  wrote:
> Hi List,
>
> I am trying to write a crawler to go through web pages at
> http://www.freebookspot.es/CompactDefault.aspx?Keyword=. But I am not
> quite familiar with how asp uses _doPostBack function with the "next"
> button below the book list to advance to the next page. I hope someone
> who knows ASP well can help out here. I need to know how to retrieve
> next page with PHP code.
>
> Kind regards,
> Tom


Looking at that page source, I think this might be a bit problematic.

Notice that practically the whole page is inside a form. When you get
down to the "Next> " button, that is going to sumbmit the form with
it's appropriate fields set. If you look at the beginning of the form,
you'll see some interesting fields, one in particular, __VIEWSTATE is
pretty clearly an encoded value of some sort.

When your crawler parses the page, it will have to stash the field
values that the form sets in order to process the form correctly to
get the next page of entries by simulating a POST-data submit. This is
(probably?) most easily handled via libcurl.

Unsolicited advice: Many sites do not appreciate scraping activity;
make sure your crawler obeys robots.txt rules, and do not overtax the
site with crawler activity.

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



Re: [PHP] get content rss feed

2012-05-04 Thread tamouse mailing lists
On Wed, May 2, 2012 at 7:00 AM, Doeke Wartena  wrote:
> I try to get the content from the following rss feed
> http://www.adafruit.com/blog/feed/
>
> I want to store it in a database in order to use it for a school assignment.
> If i look in my browser to the feed then i see content and description,
> however if i try to get them with php then description is this:
>
> [description] => SimpleXMLElement Object
>        (
>        )
>
>
> and content is gone.
>
>
> --
> $db = dbConnect();
>
> $xml =  getFileContents("http://www.adafruit.com/blog/feed/";);
> $xmlTree = new SimpleXMLElement($xml);
>
> for($i = count($xmlTree->channel->item)-1; $i >= 0; $i--) {
> $item = $xmlTree->channel->item[$i];
>  echo "";
> print_r($item);
> echo "";
> }
>
> dbClose($db);
>
> ?>
> --
>
> this is 1 part of the print_r:
>
> SimpleXMLElement Object
> (
>    [title] => Birth of the ARM: Acorn Archimedes Promo from 1987
>    [link] => 
> http://www.adafruit.com/blog/2012/04/28/birth-of-the-arm-acorn-archimedes-promo-from-1987/
>    [comments] =>
> http://www.adafruit.com/blog/2012/04/28/birth-of-the-arm-acorn-archimedes-promo-from-1987/#comments
>    [pubDate] => Sat, 28 Apr 2012 04:01:35 +
>    [category] => Array
>        (
>            [0] => SimpleXMLElement Object
>                (
>                )
>
>            [1] => SimpleXMLElement Object
>                (
>                )
>
>        )
>
>    [guid] => http://www.adafruit.com/blog/?p=30498
>    [description] => SimpleXMLElement Object
>        (
>        )
>
> )
>
> I guess content is gone cause it's like this:
>
> 
>
> And description is gone cause it's like this:
>
> 

Re: [PHP] Running through an enormous SQL file

2012-05-04 Thread tamouse mailing lists
Please put replies at BOTTOM

On Fri, May 4, 2012 at 9:24 PM, Brian Dunning  wrote:
> How would you launch that from PHP?
>
> On May 4, 2012, at 6:11 PM, tamouse mailing lists wrote:
>
>> Is there any need to use PHP with this at all? If it's already in SQL,
>> can't you just feed it to mysql?


It's a standard command you would launch via [exec or
shell_exec](http://us.php.net/manual/en/book.exec.php)

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



Re: [PHP] function

2012-05-04 Thread tamouse mailing lists
On Fri, May 4, 2012 at 9:18 PM, Jim Giner  wrote:
> But the OP says "function is defined inside a different function".  Your
> theories to a solution don't fit that problem.
[snip]
> But the OP says "function is defined inside a different function".  Your
> theories to a solution don't fit that problem.
>
> (Sorry you all had to read thru so much stuff just to get to my one-line
> response.)

There's no need to include something if it turns out to be irrelevant.

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



Re: [PHP] function

2012-05-04 Thread tamouse mailing lists
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott
 wrote:
> I need to access a FUNCTION I programmed within a different FUNCTION.  Are 
> these able to be passed like a variable?  Or are they able to become like a 
> $_SESSION variable in nature?  How am I able to do this?
>
> I am essentially programming:
>
> ===
> function name( $flag1, $flag2 ) {
>
> # some PHP
>
> echo name_of_a_different_function( $flag1 , $flag2 );
>
> }
> ===
>
> The error I am receiving is “Call to undefined function 
> name_of_a_different_function”

Thanks to Jim, I understand a bit more, however, I still do not see
where name_of_a_different_function is being defined. Rather than
suppose something, please post the function where
name_of_a_different_function is defined.

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



Re: [PHP] code deployment through php

2012-05-04 Thread tamouse mailing lists
On Wed, May 2, 2012 at 5:23 AM, rene7705  wrote:
> On Wed, May 2, 2012 at 11:47 AM, rene7705  wrote:
>
>> I can't use anything like git on my shared hoster. But I suppose I could
>> use something like git at home, and use a sync script like I posted in my
>> OP on the shared hoster.
>>
>>
>>
> Maybe you git gurus can help me along a bit further.
>
> I've managed to install msysgit and get it to work on my windows dev box,
> so far so good.
>
> Now, I'm wondering how to set up my repositories. The last cvs I used was
> Microsoft's visual source control back in the 90's, so I'm very rusty. At
> the same time, I'd prefer not to experiment too much..
>
> I've got a tree structure in a folder called simply "code", that I have in
> several locations on my windows box.
>
> Each site that I develop for has a folder in .../htdocs/sites/somedomain.com,
> and many of these sites will need a copy of the common "code" folder in
> them. I can restrict myself to developing in one domain's subdir only.
> The non-common code for each domain is designed to run from any
> $_SERVER['SERVER_NAME'] and any sub-directory it happens to be in. In other
> words, http://my-dev-box.biz/sites/somedomain.com/ will show the same thing
> from windowze as http://somedomain.com will from shared hosted linux.
>
> I would also like to version control the non-common code for each domain.
>
> And I would like to store the entire repository on my windows box at home
> in 2 or 3 specific locations (on seperate disks encrypted with truecrypt.org,
> and also a truecrypted usb disk, if and when that's plugged in).
>
> For distributing the common code to the shared hosted live server (my
> workflow is to check finalized changes on my win box against all my sites
> that used the common code base, before deploying to the shared hoster live
> server), I can simply FTP one finalized copy and use the simplest of rm -rf
> and cp -r commands in a short script to distribute the changes. I could
> even do without the PHP filesync code I posted earlier (altho it was fun to
> build! :)
>
> That darn hoster of mine won't support git on shared hosting, only on much
> more expensive virtual dedicated and dedicated plans :(
> But I've also found
> http://serverfault.com/questions/26836/setting-up-a-git-repo-on-my-godaddy-hosting-plan
>  and
> http://www.lyraphase.com/wp/uncategorized/how-to-build-git-for-a-host-with-no-compiler/
> that
> show me how I might get git running on my (kinda lame now) shared hosting
> account.
>
> Maybe a stupid question, but would perhaps copying the common code around
> with a simple script be faster than multiple pushes by git?


Using git, you can set up either publicly hosted repositories on
github.com or gitorious.org or perhaps other public repo places. If
you don't want you code to be publicly available, you can set up
private repositories as well.

Not being familiar with Windows implementations much at all, I can't
tell you specifically what to do with msysgit, so these will be more
generic instructions.

I'm going to assume you don't have a host somewhere with ssh access.
In this case you'll most likely want/need to set up your repository on
your local system. (Note that it isn't *strictly* necessary to have a
repository -- you can clone a new tree from the existing code tree,
however having a repository can ensure a clean code set in case your
working tree gets out of sync somehow.)

(These instructions are modified from
http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux
)

First, create a directory you want to hold all of your local
repositories (such as C:\User\rene\MyRepositories). Then create a
subdirectory off that to hold your server/application common code
(C:\Users\rene\MyRepositories\commoncode).

Make that directory (..\commoncode) a *bare* repository. (Not sure how
that's done with msysgit, but the basic git command is: "git init
--bare C:\Users\rene\MyRepositories\commoncode")

Then you add the repository as a remote to the working tree: git
remote add origin C:\Users\rene\MyRepositories\commoncode

Now you can push commits to your repository with the following sequence:

git add 
git commit
git push origin master

Now, to *deploy*, you can do the following:

Somewhere outside your working tree, create a directory called "deploy":

mkdir C:\Users\rene\deploy

Then clone your the repository of your commond code:

git clone C:\Users\rene\MyRepositories\commoncode cleancode-20120404

Then you can ftp the contents of cleancode-20120404 to your server as needed.

Sorry to be unable to tell you the exact steps with msysgit, but I
hope you can interpolate from the commands above.

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



Re: [PHP] Best practice question regarding set_include_path()

2012-05-10 Thread tamouse mailing lists
On Thu, May 10, 2012 at 1:50 PM, admin  wrote:
>
>
> -Original Message-
> From: Al [mailto:n...@ridersite.org]
> Sent: Thursday, May 10, 2012 11:44 AM
> To: php-general@lists.php.net
> Subject: [PHP] Best practice question regarding set_include_path()
>
> For my applications, I've been using includes and other file addressing by
> using the doc root as the base dir.   e.g.
> require_once $_SERVER['DOCUMENT_ROOT'] .
> '/miniRegDB/includes/miniRegDBconfig.php';
>
> Recently, I ran into a problem with a new installation on a shared host
> where the doc root was assigned in an unusual manner. I rather not require
> setting a custom base dir [instead of $_SERVER['DOCUMENT_ROOT']'] for my
> applications.
>
> So, I was wondering if it would be good practice to use the
> set_include_path() and add the base dir for my applications.  I've used this
> for dealing with Pear function files on shared servers and had no problems.
>
> Need some guidance regarding this subject.
>
> Thanks
>
> --
>
> I use define to set the application path
> define('BASE_PATH','C:\\inetpub\\vhosts\\yourwebsite.com\\httpdocs\\');
>
> Example:
> require_once (BASE_PATH. '/miniRegDB/includes/miniRegDBconfig.php');
>
>
> works great for JQuery paths
>
> 
> $(document).ready(function() {
> $('#dareport').html(' />');
> });
> 
>
> To me it is much better than set_include_path() but works in the same
> premise
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

I tend to use a slightly more portable version:

define('APP_ROOT',dirname(__FILE__));

in a configuration file. (If the configuration file happens to be at a
different depth than the main application file(s), I stack on more
dirname's to get back to the application root.)

Similarly, I usually need an application URL path. This can be
trickier, depending on how you structure your application. This
generally works for the applications I develop:

define('APP_URL_BASE','http://'.$_SERVER['HOST_NAME'].dirname($_SERVER['SCRIPT_NAME']));

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



Re: [PHP] Converting date string to unix timestamp

2012-05-13 Thread tamouse mailing lists
On Fri, May 11, 2012 at 8:46 PM, Karl DeSaulniers  wrote:
> On another note, just curious why I keep getting your responses, but don't
> get the emails that I post.
> Anyone else having trouble with the list like that?

That is how the mailing list works. You don't see the messages you send.

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



Re: [PHP] regexp novice

2012-05-18 Thread tamouse mailing lists
On Thu, May 17, 2012 at 3:37 PM, Jim Giner  wrote:
> ok - finally had to come up with my own regexp - and am failing.
>
> Trying to validate an input of a time value in the format hh:mm, wherein
> I'll accept anything like the following:
> hmm
> hhmm
> h:mm
> hh:mm
>
> in a 12 hour format.  My problem is my test is ok'ing an input of 1300.
>
> Here is my test:
>
>  if (0 == preg_match("/([0][1-9]|[1][0-2]|[1-9]):[0-5][0-9]/",$t))
>    return true;
> else
>    return false;
>
> Can someone help me correct my regexp?

If the ":" separator is inserted before the regex check, the following
should suffice:

'/^(0?[1-9]|1[12]):([0-5][0-9])$/'

Test script:

http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] errors not showing

2012-05-19 Thread tamouse mailing lists
On Sat, May 19, 2012 at 11:16 PM, Tim Dunphy  wrote:
> Hello Simon,
>
>  Thanks for your response.
>
>  However I still can't seem to get errors to show up.
>
> [dunphy@localhost:~/jf-current] #cat /private/etc/php.ini | grep -e
> error_reporting -e display_errors
> ; display_errors
> ; error_reporting
> error_reporting = E_ALL & E_NOTICE
> ;error_reporting = E_ALL & ~E_DEPRECATED
> display_errors = On
> ; separately from display_errors. PHP's default behavior is to suppress those
> ; Eval the expression with current error_reporting().  Set to true if you want
> ; error_reporting(0) around the eval().
>
> [dunphy@localhost:~/jf-current] #sudo apachectl -t
> Syntax OK
>
> [dunphy@localhost:~/jf-current] #sudo apachectl restart
>
>
> [dunphy@localhost:~/jf-current] #uname -a
> Darwin localhost 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7
> 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 i386
>
> I was wondering if there might be something else I might've missed?
>
> Thanks
> Tim
>
> On Sat, May 19, 2012 at 11:57 PM, Simon J Welsh  wrote:
>> 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/
>>
>
>
>
> --
> GPG me!!
>
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Are these syntax errors or run-time errors? The former won't display
to the page at all, as they abort PHP before that point. Those written
to wherever PHP is set to log errors, which might be the same as the
apache error log unless you've set something specifically for it in
php.ini.

The best way I've found to suss out syntax errors is to "lint" the
source file with php -l from the command line.

On the other hand, if they are not syntax errors, then make sure you
set error_reporting and display_errors (I also always set
display_startup_errors as well) soon enough to catch them (and that
nothing you include turns them off).

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



Re: [PHP] errors not showing

2012-05-20 Thread tamouse mailing lists
On Sun, May 20, 2012 at 3:30 PM, Maciek Sokolewicz
 wrote:
> On 20-05-2012 07:17, tamouse mailing lists wrote:
>>
>> Are these syntax errors or run-time errors? The former won't display
>> to the page at all, as they abort PHP before that point. Those written
>> to wherever PHP is set to log errors, which might be the same as the
>> apache error log unless you've set something specifically for it in
>> php.ini.
>>
>> The best way I've found to suss out syntax errors is to "lint" the
>> source file with php -l from the command line.
>>
>> On the other hand, if they are not syntax errors, then make sure you
>> set error_reporting and display_errors (I also always set
>> display_startup_errors as well) soon enough to catch them (and that
>> nothing you include turns them off).
>
>
> I always find it useful to check these values not by grep'ing the php.ini
> file, but by checking phpinfo() output. Just make a new file with
>  phpinfo();
>
> in it, and run it in the browser. That will show you the values of
> display_errors and error_reporting that are actually used. I have seen cases
> where the php.ini file a person thought was being used was actually NOT
> used, and as such changing values inside that file had no effect.
>
> - Tul

Good point! Seems best to see what the application believes is
happening. The phpinfo() will also tell you just which php.ini file(s)
is(are) being read. Usual caveats about leaving such a file
unprotected on a publicly accessible server and what not.

-- 
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 tamouse mailing lists
On Mon, May 21, 2012 at 7:31 AM, rene7705  wrote:
> On Mon, May 21, 2012 at 1:17 PM, Simon Schick
>  wrote:
>> Specially the function rajmvServiceLog_graphs_raphael_calculateData() with a
>> code of ca. 280 lines is quite long ...
>
> 280 lines is long?! :)

In general, yes. 280 lines is long. Too long, likely. Usually it
indicates you aren't designing your code in a top-down fashion, and it
is a high candidate for refactoring in order to break out into
reusable functions. A rule of thumb is no more than 50 lines per
function, most much less. Back in the day when we didn't have nifty
gui screens and an 24 line terminals (yay green on black!), if a
function exceeded one printed page, it was deemed too long and marked
for refactoring.

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



[PHP] Re: Function size

2012-05-24 Thread tamouse mailing lists
On May 23, 2012 9:14 AM, "Tedd Sperling"  wrote:
>
> Hi gang:
>
> On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote:
> >  A rule of thumb is no more than 50 lines per
> > function, most much less. Back in the day when we didn't have nifty
> > gui screens and an 24 line terminals (yay green on black!), if a
> > function exceeded one printed page, it was deemed too long and marked
> > for refactoring.
>
> You hit upon a theory of mine -- and that is our functions grow in size
up to our ability to view them in their totality. When our functions get
beyond that limit, we tend to refactor and reduce.
>
> I know from the last several decades of programming, my functions have
increased in number of lines. But, they have reached a limit that limit is
generally about the number of lines I can read in half of my monitor's
height. This of course, is dependent on monitor resolution, font-size, and
how far I am sitting from the monitor. But I think this is a natural and
physical limit that we don't normally recognize. I can cite studies that
support my theory.
>
> It would be an interesting survey to ask programmers to review their code
and provide the average number of lines in their functions AND how many
lines of code their monitor's can display. In other words, look at your
editor; count the number of lines your monitor can display; estimate the
number of lines in your average function; and report the findings.  For
example, mine is about half -- my monitor can display 55 lines of code and
my average function is around 25 lines. YMMV.
>
> Interesting, yes?
>
> Cheers,
>
> tedd
>
>
> _
> tedd.sperl...@gmail.com
> http://sperling.com
>
>
>
>
>

Yes, I think that is *exactly* the criterion-- not a mystery or an emergent
thing, really, was a pretty expicit reasoning--being able to see/scan the
entire function on one page (or now in one screenful) makes it much easier
to see what happens in the function, where blocks open/close, and it forces
one to break up code into logical units.


Re: [PHP] Re: Function size

2012-05-31 Thread tamouse mailing lists
On Tue, May 29, 2012 at 2:52 AM, Tony Marston
 wrote:
> On May 21, 2012, at 8:32 PM, tamouse mailing lists wrote:
>>  A rule of thumb is no more than 50 lines per
>> function, most much less. Back in the day when we didn't have nifty
>> gui screens and an 24 line terminals (yay green on black!), if a
>> function exceeded one printed page, it was deemed too long and marked
>> for refactoring.
>
> I think the idea of setting an arbitrary limit on the number of lines that a
> function should contain is quite ludicrous and something which I will
> completely ignore. If a function requires a hundred or more lines then so be
> it. The only reason to take a block of code and put it into its own function
> is when that code is likely to be called more than once so that it conforms
> to the DRY principle. If it is only ever used in one place then there is no
> point.


You obviously haven't spent much time maintaining other people's code.
There is a point: if you are unfamiliar with code, wading through
screens and screens of a function to find things like block
beginning/ends makes for difficult time finding places where changes
need to be made.

If you will never have your code maintained by anyone else, or
collaborate with anyone else, feel free to do what you want.



>
> The problems I have with creating lots of small used-only-once functions is
> as follows:
> - you have to create a meaningful name for each function.

Yes, you do, which is also considered a hallmark of good design.

> - all those functions should be arranged in alphabetical order within their
> containing file - having them in a random sequence makes it difficult to
> find the one you want.

Also correct; this is a key point in making sure your scripts are maintainable.

> - when browsing through the code you have to keep jumping to another
> function, and then returning to where you came from.
>
> I don't know about you, but I would rather use the scroll wheel on my mouse
> than keep jumping from one position in the file to another.

May I suggest an editor/IDE that lets you navigate to functions directly, then?

> Another problem I have encountered in the past with such an idea is that it
> encourages a stupid programmer to decrease the number of lines of code by
> compressing as many statements as possible into a single line, which then
> makes the code less easy to read and understand. This is much worse than
> having more than 20 lines in a function.

There are counterbalancing things as well. If the only aspect of one's
coding standards are "make it fit on one screen" then yes, you might
see someone idiotic enough to do that. However, a good set of coding
standards includes things which will prevent this, such as not
stacking code like that.

> Whether a file contains 10 functions of 100 lines each, or 100 functions of
> 10 lines each, you still end up with 1000 lines of code. If you do not have
> the mental capacity to deal with a 100-line function then you are in the
> wrong job.

The rules of thumb for coding standards are for maintainability,
primarily, so throwing up strawmen to try to weasel out of an idea is
pretty specious.

If you do not care about how much time it takes to fix defects in
other people's code, then I hope you remain a solitary programmer and
don't expect anyone else to use your code, otherwise, you are in the
wrong job.

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



Re: [PHP] cyberweaponry

2012-05-31 Thread tamouse mailing lists
On Thu, May 31, 2012 at 12:21 PM, Tedd Sperling  wrote:
> I watched a interview today where an security expert claimed that the Flame 
> Virus was written in a scripted language named lua (http://www.lua.org/).

Is the interview online someplace? (Youtube?)

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



Re: [PHP] Uploading large files with HTTP_Request class

2012-05-31 Thread tamouse mailing lists
On Thu, May 31, 2012 at 5:28 AM, Voß, Marko  wrote:
> Hello,
>
> I need to perform uploading of large files using the HTTP_Request class:
>
> http://pear.php.net/manual/package.http.http-request.php
>
> I am *not* using this one:
>
> http://php.net/manual/en/class.httprequest.php
>
>
> The HTTP_Request class support the following functions:
>
> setBody() and addFile()
>
> The addFile()-function however simulates a form field and the server 
> application does not read the incoming file from such a field. I have to put 
> the file content as a stream through the body.
>
> Adding the file content using the setBody()-function will of course cause an 
> out of memory error:
>
> $fp = fopen($filename, 'r');
> $request->setBody(fread($fp, $filesize($filename)));
> $fclose($fp);
> $response = $request->sendRequest();
>
>
> How am I supposed to do that with this class? Are there any alternatives, 
> which do not force me to add new PHP dependancies/libraries to the project? I 
> am writing a library and do not want to force the users to add dependancies 
> to their projects in order to use this library.
>
> I am currently using PHP 5.3.0.
>
>
> Thank you and best regards,
> Marko
>
>
> ---
>
> Fachinformationszentrum Karlsruhe, Gesellschaft für 
> wissenschaftlich-technische Information mbH.
> Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB 
> 101892.
> Geschäftsführerin: Sabine Brünger-Weilandt.
> Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Does the receiving server only accept uploads via HTTP? Or is there
another protocol you could use? I'm not aware of anyway via HTTP you
can send "chunks" up; as far as I know, that only works for
server->client transfers.

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



Re: [PHP] Uploading large files with HTTP_Request class

2012-05-31 Thread tamouse mailing lists
On Thu, May 31, 2012 at 5:28 AM, Voß, Marko  wrote:
> I need to perform uploading of large files using the HTTP_Request class:
> http://pear.php.net/manual/package.http.http-request.php
> The HTTP_Request class support the following functions:
> setBody() and addFile()

Reading the above, and checking on the documentation, I notice an inconsistency.

I only find the setBody() method in HTTP_Request2, while addFile() is
in HTTP_Request. The correct method for adding files in HTTP_Request2
is addUpload() (which still may not work given the limitations of the
upstream server).

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



Re: [PHP] Your Amazon.com order confirmation.

2012-06-09 Thread tamouse mailing lists
On Fri, Jun 8, 2012 at 9:23 AM, Dan McCullough  wrote:
> I was hoping for a TV

I'm still waiting on my delivery of a case of tuscan whole milk

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



Re: [PHP] Re: define()

2012-06-16 Thread tamouse mailing lists
On Sat, Jun 16, 2012 at 7:17 AM, Ashley Sheridan
 wrote:
> On Sat, 2012-06-16 at 07:09 -0500, Karl DeSaulniers wrote:
>
>> On Jun 16, 2012, at 6:39 AM, Maciek Sokolewicz wrote:
>>
>> > On 16-06-2012 08:36, Karl DeSaulniers wrote:
>> >> Quick question phprz. Is it ok to put a token inside a define()
>> >> statement?
>> >>
>> >> IE:
>> >> define('TOKEN', $sometoken);
>> >>
>> >> I guess what I am really after is if this can be read by a hacker?
>> >> I may be misguided as to what define()'s parameters are.
>> >> Once you define something it becomes a server variable?
>> >> And server variables are easy to read/get ?
>> >>
>> >> If it is unsafe, what is the best method of storing/using a token so
>> >> that it can be called at will?
>> >> Kind of like a global, just more secure. Can you secure a define
>> >> statement?
>> >>
>> >> TIA,
>> >>
>> >> Best,
>> >> Karl DeSaulniers
>> >> Design Drumm
>> >> http://designdrumm.com
>> >>
>> >>
>> >
>> > I don't think you understand what define does, or what a constant is.
>> >
>> > The define function literally "defines" a constant. That is, it
>> > creates a constant in your script.
>> > A constant isn't a server variable, it's not some kind of special
>> > global whatever.
>> >
>> > A constant is a kind of variable, but which is constant; that is, it
>> > can not change value once set. Constants in PHP look like variables,
>> > only without the preceding $-mark. They are not inherently safer or
>> > better than normal variables.
>> >
>> > Now, the question we would all like to pose is: "what are you trying
>> > to do?". You say you're looking for the best method of storing/using
>> > a token to be called at will. Then of course a good question would
>> > be "what do you mean by 'token'?" and what do you want to do with
>> > that 'token'? Why is that 'token' so important to you?
>>
>> Thanks for the reply. I had a feeling I was off-track.
>> I am using the token for a paypal verification. Paypals PDT.
>> Would like to know how to store safely in my config file to use in my
>> scripts.
>>
>> Karl DeSaulniers
>> Design Drumm
>> http://designdrumm.com
>>
>>
>
>
> Store it in a PHP script outside of document root if you can, this
> prevents it ever being seen if the server is misconfigured to not parse
> php scripts properly.
>
> Try to secure all the scripts on the site, as any of them could be a way
> in, allowing someone to execute their own code on the server. This is
> standard practice generally though.
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

For credentials, such as tokens, passphrases, etc, I don't tend to
store these in any particular language so that I can read and use them
no matter what implementation language I'm using.

These are stored outside of any server path, and strict
permissions/ACL controlled.

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



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

2012-06-26 Thread tamouse mailing lists
On Jun 26, 2012 5:31 PM, "Stefan Wixfort"  wrote:
>
> On 26.06.2012 23:48, Simon J Welsh wrote:
>>
>>
>> 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.
>
>
> Clever gi... er guy...
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Oh you know randall is all over this: http://xkcd.com/1073/


Re: [PHP] Re: php form action breaks script

2012-06-27 Thread tamouse mailing lists
On Wed, Jun 27, 2012 at 7:17 PM, Tim Dunphy  wrote:
> Hey guys,
>
> It's been a little while since I've toyed with this, and I hope you
> don't mind my coming back to you for some more advice. But I've
> enjoyed some limited success with David R's advice regarding adding
> some strong quoting to the mix. Here is what I last tried -
>
>  

Just a wee typo here: You've quoted '[PHP_SELF' -- the extra bracket
at the beginning what's wrong there. Should just be 'PHP_SELF'.

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



Re: [PHP] Re: php form action breaks script

2012-06-27 Thread tamouse mailing lists
On Wed, Jun 27, 2012 at 7:17 PM, Tim Dunphy  wrote:


One more little thing:

These notices:

> Notice: Undefined index: subject in
> /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php
> on line 23 Notice: Undefined index: elvismail in
> /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php

show up because you are processing form fields in $_POST when there
might not be any yet.

These lines:

>  $from = 'bluethu...@jokefire.com';
>  $subject = $_POST['subject'];
>  $text = $_POST['elvismail'];
>  $output_form = "false";


Should appear *after* this line:

>  if (isset($_POST['Submit'])) {


You should also check the $_POST entries for 'subject' and 'elvismail'
to make sure they are set to avoid the notices, even if you do move
them after the submit check. You never know!

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



Re: [PHP] slicing and dicing strings

2012-06-27 Thread tamouse mailing lists
On Wed, Jun 27, 2012 at 5:15 PM, Kirk Bailey  wrote:
> ok, it slices and dices, but how?
> in python, to print all but the last char in string FOO, we say
> print FOO[:-1]
> But this seems to bark like a basset hound in php. Whyfore?

As said, PHP is not Python. Pretty much *nothing* else is Python.

That said, the trope still has legs in PHP:

>From  :

   "If start is negative, the returned string will start at the
   start'th character from the end of string."

> Now tihs tyro is seeking sage words to help me understand this.
> RTFM is not sage words; if you don't want to help me please don't waste the
> bandwidth.

RTFM with no hint of where to look is a problem. But the dictum of
"Read here in the manual" will surely be the best thing. You will then
know where to look for future questions.

> Would anyone care to help me understand this without dedicating 4 precious
> and in over demand/under supply hours to RTFM?

You may not have 4 precious and overdemanded/undersupplied hours, but
at some point everyone who can answer this has had to slog through the
manual; we haven't just been lounging in our opulence pouring over the
documentation out of some need to aleviate our boredom. Nor is anyone
on this list to spend their time providing answers which *are* readily
available with just a bit of google-fu.

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



Re: [PHP] Depreciation message I can't make out....

2012-06-28 Thread tamouse mailing lists
On Thu, Jun 28, 2012 at 1:00 PM, Daniel Brown  wrote:
>>  PHP Deprecated:  Comments starting with '#' are deprecated in
>> /web/conf/php5.ini on line 1256 in Unknown on line 0
>
>    Comment-out, using semicolons (;), any comments in your
> /web/conf/php5.ini file that begin with the hashmark (#), and then
> also comment-out (;) the magic_quotes_gpc line.

Just a quick followup -- # comments are deprecated for .ini files,
only, correct? They are still full citizens in php source, aren't
they?

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



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

2012-06-28 Thread tamouse mailing lists
On Wed, Jun 27, 2012 at 9:42 AM, Tedd Sperling  wrote:
> On Jun 26, 2012, at 3:21 PM, Al  wrote:
>
>> No postings for days.
>>
>
> Maybe everyone learned it -- no new questions.
>
> Cheers,
>
> tedd

We now all have php.net open all the time so no more questions need to
be asked! :>

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



Re: [PHP] log tailing

2012-06-29 Thread tamouse mailing lists
On Fri, Jun 29, 2012 at 3:49 AM, Mihamina Rakotomandimby
 wrote:
> I have a /var/log/messages and /var/log/syslog file to parse to extract
> information from.
>
> I have the to extract the date, and some information in the line.
[snip]
> I just need help on the right regexp function to use.
> Would you know some PHP/regexp tutorials for that?

The best documentation I've ever found on Regexes is O'Reilly's
"Mastering Regular Expressions" (3rd ed is 2006, but REs haven't
changed since then).



Only problem is it is hella expensive. (Well another problem is it is
hella big: >500 pages.)

Apart from that, there are *tons* of tutorials on the net. Just google
up "regular expression tutorials" and you should see pages and pages
of them.

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



Re: [PHP] Depreciation message I can't make out....

2012-06-30 Thread tamouse mailing lists
On Sat, Jun 30, 2012 at 12:57 PM, Gary Lebowitz  wrote:
> By the way, I told GoDaddy about the # deprecation issue and they told me
> that I could simply change my root directory php5.ini file. But the error
> message is related to the PHP.ini file in /web/config, as I said. I could
> almost hear them shrugging their shoulders, what-me-worry style. If anyone
> with more might than i could explain this error might affect others when
> multiplied hundreds of times it could be useful.
>
> Am 30.06.2012 19:23 schrieb "Daniel Brown" :
>>
>> On Thu, Jun 28, 2012 at 8:37 PM, tamouse mailing lists
>>  wrote:
>> >
>> > Just a quick followup -- # comments are deprecated for .ini files,
>> > only, correct? They are still full citizens in php source, aren't
>> > they?
>>
>>    Correct, Tam.
>>
>> --
>> 
>> Network Infrastructure Manager
>> http://www.php.net/
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>

> By the way, I told GoDaddy about the # deprecation issue and they told me
> that I could simply change my root directory php5.ini file. But the error
> message is related to the PHP.ini file in /web/config, as I said. I could
> almost hear them shrugging their shoulders, what-me-worry style. If anyone
> with more might than i could explain this error might affect others when
> multiplied hundreds of times it could be useful.
>

Sadly, my only advice is to get away from GoDaddy.

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



Fwd: Re: [PHP] log tailing

2012-06-30 Thread tamouse mailing lists
-- Forwarded message --
From: "tamouse mailing lists" 
Date: Jun 30, 2012 4:35 PM
Subject: Re: [PHP] log tailing
To: "Daniel Brown" 

On Jun 30, 2012 1:34 PM, "Daniel Brown"  wrote:
>
> On Sat, Jun 30, 2012 at 2:30 PM, Daniel Brown  wrote:
> >
> >  >
> > $ssh_entries = explode(PHP_EOL,trim(`tail /var/log/syslog | awk
> > {'print $1,$2,$3 "|" $5 "|" $11'}`));
>
>Actually, the above was intended to grab just sshd entries, so
> instead of 'tail' you should use 'grep sshd' in the line above.
>
>
> > foreach ($ssh_entries as $s) {
> >$l = explode('|',$s);
> >
> >// Remember to do whatever sanity necessary!
> >$sql = "INSERT INTO ssh_activity
> > VALUES('".$l[0]."','".$l[1]."','".$l[2]."')";
> > }
> > ?>
> >
> > --
> > 
> > Network Infrastructure Manager
> > http://www.php.net/
>
>
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Crud-- sent to Dan instead of list:

Or just let awk do it:

tail /var/log/syslog | awk '/sshd/{print($1,$2,$3 "|" $5 "|" $11)}'


Re: [PHP] Hello again

2012-07-02 Thread tamouse mailing lists
On Sun, Jul 1, 2012 at 6:21 PM, RGraph.net support  wrote:
> Just thought I'd say hello again. Back to brush up on my PHP a little
> after a bit of a break - more reading than replying I'd imagine. I
> have some pretty bad jokes too that I might surreptitiously insert
> here and there...

Welcome back. Friday is mainly the free-for-all day (philosophical
questions, puns, jokes)

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



Re: [PHP] PDO Prevent duplicate field names?

2012-07-03 Thread tamouse mailing lists
On Mon, Jul 2, 2012 at 5:38 PM, Scott Baker  wrote:
> It was my mistake, and the SQL was easily fixed. But it woulda been nice
> to have PHP realize there was a dupe when it was building that array to
> return to me.

This is just not a province of PHP. What sort of behaviour would one
expect PHP to do given this scenario? It is surely not an error in
every case; I can see some code relying on this exact behaviour.
Making it some sort of option in PHP increases the complexity a great
deal, not only in trying to determine how to design and then *change*
the API to accommodate it, but in figuring out what exactly one might
*do*. Since SQL is a completely separate language from PHP, it makes
much more sense to learn to deal with these thing separately, and
understand what your SQL is doing. Indeed, SQL will happily return
multiple columns with the same column name; you must be aware of this
when writing it.

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



Re: [PHP] How does this code work?

2012-07-03 Thread tamouse mailing lists
On Tue, Jul 3, 2012 at 2:31 AM, Robert Williams  wrote:
> On Jul 2, 2012, at 22:15, "Jim Lucas"  wrote:
> Hmm, I wonder if those thirty years are having a different sort of impact on 
> me, in the form of decaying eyesight

I've had to tweak up the default fonts on things... *sigh*

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



Re: [PHP] How to make a secure download ?

2012-07-08 Thread tamouse mailing lists
On Thu, Jul 5, 2012 at 10:17 AM, Gibbs  wrote:
> On 05/07/12 14:32, donkfat...@donkfather.eu wrote:
>>
>> Hi,
>>
>> I am trying to put a file to download. I want it secure so only the people
>> having the password can access it.
>> I made a page that requires a password.. if the password is correct it
>> changes the password send it on my mail and redirects
>> the user to another script. This script searches in the database for the
>> id given with GET and finds the name of the file
>> which is md5(something). it changes the name of the file in md5(smth
>> else). After that it searches in the download folder
>>  for a file named md5(smth else). if it finds the file it gives you the
>> link to the file.
>> So i need to find a way to change the filename after the user downloads
>> the file. to keep it secure so the user
>> wont be able to share the link to oters.
>>
>> if you need more info ask :D
>> thanks
>> and sorry for my bad english .
>>
>
> Sounds like you are overcomplicating it. Following what you've already done
> though...
>
> Have the original files stored somewhere outside of the web root. That way
> they aren't accessible whatsoever + you shouldn't have to change any of the
> files at any stage.
>
> Then you can simply update/change the ID that associates with it in your
> database when that URL is hit...
>
> Gibbs


It does sound a bit complicated. If I surmise correctly, what you are
attempting to do is give an authorized person the ability download a
file from your server by sending them a link to it in an email. Right
so far?

If so, here's what I suggest doing:

1) Store your downloadable content in a directory *outside of the web
server file space* (as Daniel mentioned above).

2) Keep a table of authorized people -> file download tokens, and file
download tokens -> download file spec. (You might want to also include
a back-reference for the latter so you can keep stats on files
downloaded.)

3) Write a special script that only handles downloads, not part of
your regular application.

4) When the authorized person requests the download, create a token
and store it in the data base, linking it to the person's info and the
download file spec, and send the person an email with a link to the
URL invoking the special script with token.

5) When the person clicks the link, have your script mark the token as
"used" (so it can't be used again -- or optionally keep it around and
possibly do something like record the number of downloads, ip
addresses, date/time, and so on -- can be useful also for given
someone, say, 5 legal downloads and then shutting it off).

6) Then matching the token to the file spec, deliver the contents,
appropriately setting headers as per the file contents.

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



Re: [PHP] Using named Pipes between PHP and ZIP

2012-07-08 Thread tamouse mailing lists
≈On Sun, Jul 8, 2012 at 11:30 AM, Dennis Heck  wrote:
> Hello everyone,
>
> I'm looking for a solution for the following:
> 1) collecting data from a simple html form and send them to a php script
> 2) take the data and place them in a php-generated excel sheet
> 3) zip the excel sheet and password protect the zip file (standard
> encription will be sufficent, no AES needed)
> 4) send the zip file as an email attachment
> This kind of output is fixed, changing the output is not an option.
>
> I'm ok with building the excel sheet and sending the mail, but I'm still
> trying and error with the zip. Since I need password protection in the zip,
> I cannot use the php build in zip extension. I guess I will need to call ZIP
> on the shell. I'm aware I could first save the generated excel sheet to the
> filesystem and afterwards call the zip process on the file, putting the zip
> file also to the file system. But I wonder if there's an option to stream
> the data till they finally can be put to the multipart mail - without saving
> anything to the filesystem.
>
> Here is my first try, just a little modification of the example on proc_open
> in the php docu. To keep the test simple, I load a sample xls from the
> filesystem instead of generating from the php class and output it directly
> to the browser. The script works well except one point: the file contained
> in the zip will have no name an no file extension.
>
>header ('Content-type: application/zip');
>header ('Content-Disposition: attachment; filename="download.zip"');
>
>$descriptorspec = array(
>0 => array("pipe", "r"),
>   1 => array("pipe", "w"),
>   2 => array("file", "error-output.txt", "a")
>);
>
>$dateiname = 'xyz.xls';
>$file = fread(fopen($dateiname, "r"), filesize($dateiname));
>
>$process = proc_open('zip -P 1234', $descriptorspec, $pipes);
>
>if (is_resource($process)) {
>
>fwrite($pipes[0], $file);
>fclose($pipes[0]);
>
>$zip = stream_get_contents($pipes[1]);
>fclose($pipes[1]);
>
>$return_value = proc_close($process);
>}
>
>echo $zip;
>?>
>
> So I look for an option to get the name and extension in the zipfile. Here I
> found named pipes as an option. Calling via shell, tested with a textfile in
> order to use less
>
>mkfifo xyz.txt
>less readme.txt > xyz.txt & zip output.zip -FI xyz.txt -P 1234
>rm xyz.txt
>
> Now I get a pw protected zip file containing xyz.txt. Now how can I combine
> both? How can I tell php to use the named pipe instead of stdin in
> proc_open? Or any other idea to get the file in the zip the correct name and
> extension.
>
> Thanks in advance,
> Regards,
> Dennis
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

I *think* all you need in the first paramter to proc_open is :

zip -P password - -

The first - is the zip file -- which will be send to stdout.
The second - is the input -- which you should pipe your spreadsheet into.

Good luck!

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



Re: [PHP] Re: Find match of string if only at end of string

2012-07-11 Thread tamouse mailing lists
On Wed, Jul 11, 2012 at 11:45 AM, Marc Guay  wrote:
> Answered it myself (funny how writing out a problem as descriptively
> as possible makes the brain work better).
>
> $end_of_url = substr("http://domain.com/about/page/subpage/";,
> strlen("/about/page/") * -1);
> $same_post = ($end_of_url == "/about/page/");

or regex: ':/about/page/:$'

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



[PHP] PDO: extend or encapsulate?

2012-07-12 Thread tamouse mailing lists
It's Friday, so...

Yes, it's true, I have just started looking at using PDO instead of
mysqli -- a bit behind the times...

My question at this stage, is do people tend to extend the PDO class
for their own use, or encapsulate it in a class (or do most people use
it mostly in procedural code?)

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



Re: [PHP] PDO: extend or encapsulate?

2012-07-14 Thread tamouse mailing lists
On Sat, Jul 14, 2012 at 12:04 AM, Paul M Foster  wrote:
> On Fri, Jul 13, 2012 at 12:06:22AM -0500, tamouse mailing lists wrote:
>
>> It's Friday, so...
>>
>> Yes, it's true, I have just started looking at using PDO instead of
>> mysqli -- a bit behind the times...
>>
>> My question at this stage, is do people tend to extend the PDO class
>> for their own use, or encapsulate it in a class (or do most people use
>> it mostly in procedural code?)
>
> I encapsulated it in my own database class. One reason for that is that
> the PDO "class" is really two classes, which is fine for low level
> drivers but not production code that I have to use daily. A second
> reason is that many of the methods are not really necessary in a
> production environment. I want to limit the methods my code uses to
> interact with the database. Third, I wanted to handle errors and
> exceptions with my own methods, more suitable to the code I write. For
> example, a fatal error should only, but always, be issued if the
> database code is given something illegal to chew on. Anything else, like
> a failure to return the expected result, should simply yield some sort
> of sentinal value or something. If *my code* ever gives the database
> library something illegal to chew on, then it should only be because of
> my bad code, not because a user managed to somehow get bad data through.
> That is, my code should always catch illegal data before it ever gets to
> the database library. Fourth, encapsulation means that I can have the
> class itself carry around some of the data that I would normally have to
> explicitly pass around among functions. This way, I make that useful
> data (like the number of records returned from the last fetch), part of
> the "payload" of the class itself.
>
> Extension is tricky and requires a more subtle and refined knowledge of
> the classes involved. Besides, it exposes methods which I would prefer
> not be used by my code. Encapsulation limits the methods of the classes
> to just what I deem necessary and no more. I can always write new
> methods if I need them.
>
> Paul
>
> --
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com


I am rather agreeing with both of you. Back in the days I used to poke
at Java, one of the caveats was to only inherit from abstract classes,
and encapsulate final classes. It does make more sense to me that way.

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



Re: [PHP] Re: Seeking a scheduling algorithm

2012-07-14 Thread tamouse mailing lists
On Jul 14, 2012 5:34 PM, "Bill Guion"  wrote:
>
> On Jul 14, 2012, at 4:53 PM, php-general-digest-h...@lists.php.net wrote:
>
> > From: Tedd Sperling 
> > Subject: Seeking a scheduling algorithm
> > Date: July 14, 2012 4:53:15 PM EDT
> > To: php-general@lists.php.net
> >
> >
> > Hi gang:
> >
> > Does anyone have a resource, or better yet code, to solve the
scheduling problem described below?
> >
> > Let's say you have a week calendar that has openings between 8:00am to
5:00pm for Monday through Friday (40 hours).
> >
> > Then you have an assortment of appointments that must be scheduled into
the week calendar. Some of the appointments are simply a one hour per week,
while others may be two, three, four, or five times per week and each
appointment for an hour or more (up to eight hours).
> >
> > The problem is, knowing what appointments (i.e., twice a week for 2
hours, three times a week for one hour, etc.) must be scheduled for the
week, what is the most efficient way to schedule these appointments into
that week?
> >
> > The most efficient way is defined as scheduling appointments with
little, or no, gaps in between appointments. For example, four one-hour
appointments on Monday between 8:00am to 12:00pm is better than four
one-hour appointments spread out between 8:00am to 5:00pm.
> >
> > Anyone have any solutions, ideas, resources, code?
> >
> > Thanks,
> >
> > tedd
> >
> > _
> > t...@sperling.com
> > http://sperling.com
> >
>
>
> Tedd,
>
> There is an old general rule that the most time efficient way to schedule
is to put the "big" time requests on the schedule first. In this case, that
would mean schedule all five times a week requests first, then the four
times a week, then the three times a week. The two hour requests should be
scheduled next: three times a week and twice a week can be scheduled at the
same time. Then fill in the rest with the one hour requests.
>
> Hope that makes sense.
>
>  -= Bill =-
> --
>
> A closed mouth gathers no feet.
>

What this sounds like, to me, is quite similar to either a memory
allocation scheme or a disc defragmenting scheme. I haven't worked either
of those since I went to Jurassic United, though...


Re: [PHP] PDO: extend or encapsulate?

2012-07-15 Thread tamouse mailing lists
On Sun, Jul 15, 2012 at 5:50 AM, shiplu  wrote:
> From OOP point of view.
>
> Use encapsulation:
> When a class has a "has-a" relation-ship with other class you should use
> encapsulation. For example, If MyDB is a class that "has-a" pdo driver in
> it, then PDO will be encapsulated inside MyDB class. This is also called
> containment. MyDB should contain PDO.
>
> Use inheritance:
> When a class has a "is-a" relation ship with other class use inheritance.
> For example,  Dog is an Animal. so Dog should extend Animal class. MyPHPDb
> is-a PHP Database Object (aka PDO). So it'll be inheritance. MyPHPDb should
> extend PDO.
>
> Think about the relation have. Then implement it.
>
>
> --
> Shiplu.Mokadd.im
> ImgSign.com | A dynamic signature machine
> Innovation distinguishes between follower and leader
>

Yes, good: "has-a" and "is-a". In some cases, the distinction seems
clear. The think in this case, the class I'm implementing "has-a" PDO
driver, rather than "is-a" PDO driver. In this case, I'm encapsulting
the PDO classes within my class to provide removal of details from the
main program for dealing with data, which isn't particularly
interested in how that data is manipulated or stored.

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



Re: [PHP] What do you call the end-user?

2012-07-19 Thread tamouse mailing lists
On Thu, Jul 19, 2012 at 12:26 PM, Tedd Sperling  wrote:
> Hi gang:
>
> I can't wait for tomorrow -- so here's my off-topic post today.
>
> First question:
>
> What do you call the people who ultimately use your code?

It all depends on where and how my code is ultimately used. If it is
code that someone sitting at a browser making requests that end up
running code I wrote, they are a user, or where there needs to be
clarification, and end user.

> I call them the "end-user", but others have stated other terms, such as 
> "customer" or "user".

Again, it sort of depends on the disposition of the code I wrote. In
any case, "customer" to me implies some sort of delivery possibly for
remuneration. Customers tend to be singular for any given package (not
meaning exclusive) and some kind of contract is held between us.

I don't run any commercial sites for my own benefit, otherwise the
term customer might expand to people buying or trading things with me
via that site, in which case those customers become a subset of end
users as well.

Isn't this fun?

In the case where I'm developing a portion of a product that another
developer may pick up an use in application, they are "using" my code,
but are definitely quite distinct from an end-user or a customer.
Sometimes they might be called a "partner", but not always.

> Second question:
>
> Are you concerned with their ("whomever") experience in using your code?

All those various constituents have needs whom I may wish to address.
The end-user, obviously has need to be able to transact their business
in as easy a fashion as possible, and being able to trust the chain of
software and hardware that will carry out those wishes. The customer
needs to be able to trust in the product or service they are buying,
but equally, to be able to understand and navigate whatever process is
in place for our transaction. And the development partner, as well,
needs to be able to trust that the package I'm producing is documented
well enough, and it is clear and as easy as possible to integrate with
their own software.

> This question transcends your code working correctly, accurately, and 
> securely -- no need to comment on those aspects. But rather more specifically 
> do you consider how easily your "whomever" can use your work efforts?
>
> As you may have guessed - I just attended a UX conference and they provide an 
> interesting perspective on UX. I was wondering how php developers typically 
> address the subject.

This sort of thing is not only applicable to UX needs, but to many
other areas as well. It's also not limited to any particular
interface, but how that interface changes and evolves over time, and
it's responsiveness to the various constituents' needs.

> Cheers,
>
> tedd
>
> 
> t...@sperling.com
> http://sperling.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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



Re: [PHP] Creating drop-down menus

2012-07-20 Thread tamouse mailing lists
On Jul 19, 2012 8:31 PM, "Tedd Sperling"  wrote:
>
> On Jul 19, 2012, at 1:50 PM, Daniel Brown  wrote:
> >
> >As an aside on the subject of jQuery, our very own Jay Blanchard
> > has written a comprehensive book on the topic entitled "Applied
> > jQuery: Develop and Design":
> >
> >http://links.parasane.net/92xb
> >
>
> Just bought it -- thanks. I'll add it to my other three jQuery books
>
> Always support the people on this list.
>
> Cheers,
>
> tedd
>
> _
> t...@sperling.com
> http://sperling.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

I have to ask, is it available in a non-DRMed shook format?


Re: [PHP] Creating drop-down menus

2012-07-20 Thread tamouse mailing lists
On Jul 20, 2012 9:20 AM, "tamouse mailing lists" 
wrote:
>
>
> On Jul 19, 2012 8:31 PM, "Tedd Sperling"  wrote:
> >
> > On Jul 19, 2012, at 1:50 PM, Daniel Brown  wrote:
> > >
> > >As an aside on the subject of jQuery, our very own Jay Blanchard
> > > has written a comprehensive book on the topic entitled "Applied
> > > jQuery: Develop and Design":
> > >
> > >http://links.parasane.net/92xb
> > >
> >
> > Just bought it -- thanks. I'll add it to my other three jQuery books
> >
> > Always support the people on this list.
> >
> > Cheers,
> >
> > tedd
> >
> > _
> > t...@sperling.com
> > http://sperling.com
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> I have to ask, is it available in a non-DRMed shook format?

Ok, so shook is what ebook autocorrects to


Re: [PHP] Mac 10.7 Install/Copy fresh PHP over Pre-Installed PHP

2012-07-31 Thread tamouse mailing lists
Ugh. This is why I no longer want an apple computer.

On Jul 31, 2012 8:26 AM, "JeffPGMT"  wrote:
>
> AGAIN - THANKS TO ALL...
>
> IT installed XCode, here's another? command line tools sans XCode
available
> from Kenneth's github,
> https://github.com/kennethreitz/osx-gcc-installer
>
> However another irony, now that XCode is installed, in the new XCode 4.4
> command line tools are not installed by default, so I found my way to
> Preferences, Downloads, Command Line tools Install checkbox... it's
> downloading (similar to watching paint dry)
>
> JeffP...
>
> "Simon J Welsh"  wrote in message
> news:2a4921bf-db43-464b-8bbe-5ea1e3665...@simon.geek.nz...
> 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] File moving hell on Windows

2012-07-31 Thread tamouse mailing lists
On Jul 31, 2012 12:12 PM, "Brian Dunning"  wrote:
>
> Regular Windows networking.
>
> On Jul 30, 2012, at 2:29 PM, Mike Mackintosh <
mike.mackint...@angrystatic.com> wrote:
> >>
> > What protocol are you targeting? FTP, SFTP, SSH, SMB, etc?
> >
> > --
> > Mike Mackintosh
> > PHP 5.3 ZCE
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Is this a php problem?


Re: [PHP] PHP Stats

2012-07-31 Thread tamouse mailing lists
On Jul 31, 2012 12:19 PM, "Lester Caine"  wrote:
>
> Sebastian Krebs wrote:
>>
>> http://w3techs.com/technologies/details/pl-php/all/all For example. Click
>> around, nice stats there.
>
> http://w3techs.com/technologies/history_overview/programming_language/ms/yis 
> the more interesting one ... PHP usage IS still growing.
>
> --
> 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
>

Interesting to see coldfusion on there still... but not Ruby...


Re: [PHP] php safe mode no more?

2012-08-04 Thread tamouse mailing lists
What I've noticed running apache suexec + fastcgi is that the memory
requirements increased over running nonsuexec and mod_php under
apache. when i went to a nginx + fastcgi, things worked much better
overall with limited memory (i'm on 1GB limited slice, non-burstable).

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



Re: [PHP] Coding Web search engine in PHP

2012-08-06 Thread tamouse mailing lists
On Aug 6, 2012 7:33 AM, "shiplu"  wrote:
> Solr with Nutch will do it.

Where *do* come up with those names :)


Re: [PHP] PHP session variables

2012-08-14 Thread tamouse mailing lists
On Aug 13, 2012 8:01 AM, "Robert Cummings"  wrote:
>
> On 12-08-10 04:42 PM, Tedd Sperling wrote:
>>
>> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin  wrote:
>>
>>> Hi. My question will maybe out of topic, I'm sorry.
>>> How can you know that one way will be much slower than other one? I
mean, how can I learn which function is faster before I test it?
>>
>>
>> Ege:
>>
>> No your question is on topic.
>>
>> This question should be asked on the list, so I'll present Q:A instead
of answering privately
>>
>> http://www.webbytedd.com/b/timed1/
>>
>> The code is there -- if you have questions, please post them to the list.
>
>
> Ted,
>
> Please see the current signature for microtime():
>
> mixed microtime ([ bool $get_as_float = false ] )
>
> The optional paramter was added in PHP 5.0.0. I think it's safe to update
your habits :)
>
> Cheers,
> Rob.
> --
> E-Mail Disclaimer: Information contained in this message and any
> attached documents is considered confidential and legally protected.
> This message is intended solely for the addressee(s). Disclosure,
> copying, and distribution are prohibited unless authorized.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

What are the timing values if you do something besides session start with
no close?


Re: [PHP] PHP session variables

2012-08-14 Thread tamouse mailing lists
On Aug 14, 2012 1:36 AM, "tamouse mailing lists" 
wrote:
>
>
> On Aug 13, 2012 8:01 AM, "Robert Cummings"  wrote:
> >
> > On 12-08-10 04:42 PM, Tedd Sperling wrote:
> >>
> >> On Aug 10, 2012, at 1:21 PM, Ege Sertçetin 
wrote:
> >>
> >>> Hi. My question will maybe out of topic, I'm sorry.
> >>> How can you know that one way will be much slower than other one? I
mean, how can I learn which function is faster before I test it?
> >>
> >>
> >> Ege:
> >>
> >> No your question is on topic.
> >>
> >> This question should be asked on the list, so I'll present Q:A instead
of answering privately
> >>
> >> http://www.webbytedd.com/b/timed1/
> >>
> >> The code is there -- if you have questions, please post them to the
list.
> >
> >
> > Ted,
> >
> > Please see the current signature for microtime():
> >
> > mixed microtime ([ bool $get_as_float = false ] )
> >
> > The optional paramter was added in PHP 5.0.0. I think it's safe to
update your habits :)
> >
> > Cheers,
> > Rob.
> > --
> > E-Mail Disclaimer: Information contained in this message and any
> > attached documents is considered confidential and legally protected.
> > This message is intended solely for the addressee(s). Disclosure,
> > copying, and distribution are prohibited unless authorized.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> What are the timing values if you do something besides session start with
no close?

Just to clarify, since at least 4.3.x subsequent calls session_start raise
an E_NOTICE and are ignored, so you're first call is generating almost all
the time.


Re: [PHP] Need to have form protection techniques

2012-08-16 Thread tamouse mailing lists
On Thu, Aug 16, 2012 at 11:05 PM, Ansry User 01  wrote:
> I need to know the forms validity techniques for Php.

Is that all?

Seriously, that is a very lengthy discussion, and may depend on which
framework you may be using.

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



Re: [PHP] How do I do count the occurrence of each word?

2012-08-18 Thread tamouse mailing lists
On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
 wrote:
> I want to parse this text and count the occurrence of each word:
>
> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
> #Can I do this?
> $stripping = strip_tags($text); #get rid of html
> $stripping = strtolower($stripping); #put in lowercase
>
> 
> First of all I want to start AFTER the expression "News Releases" and stop
> BEFORE the next occurrence of "-30-"
>
> #This may occur an undetermined number of times on
> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>
>
> 
> Second, do I put $stripping into an array to separate each word by each
> space " "?
>
> $stripping = implode(" ", $stripping);
>
> 
> Third how do I count the number of occurrences of each word?
>
> Sample Output:
>
> determined = 4
> fire = 7
> patrol = 3
> theft = 6
> witness = 1
> witnessed = 1
>
> 
>  $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
> #echo strip_tags($text);
> #echo "\n";
> $stripping = strip_tags($text);
>
> #Get text between "News Releases" and stop before the next occurrence of
> "-30-"
>
> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
> #$stripping = str_replace("  ", " ", $stripping);# getting rid of the
> occurrences of double spaces
>
> #$stripping = strtolower($stripping);
>
> #Where do I go now?
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

This is usually a first-year CS programming problem (word frequency
counts) complicated a little bit by needing to extract the text.
You've started off fine, stripping tags, converting to lower case,
you'll want to either convert or strip HTML entities as well, deciding
what you want to do with plurals and words like "you're", "Charlie's",
"it's", etc, also whether something like RFC822 is a word or not
(mixed letters and numbers).

When you've arranged all that, splitting on white space is trivial:

$words = preg_split('/[[:space:]]+/',$text);

and then you just run through the words building an associative array
by incrementing the count of each word as the key to the array:

foreach ($words as $word) {
$freq[$word]++;
}

For output, you may want to sort the array:

ksort($freq);

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



Re: [PHP] How do I do count the occurrence of each word?

2012-08-18 Thread tamouse mailing lists
On Sun, Aug 19, 2012 at 12:38 AM, Marco Behnke  wrote:
> Am 19.08.12 06:59, schrieb tamouse mailing lists:
>> On Sat, Aug 18, 2012 at 6:44 PM, John Taylor-Johnston
>>  wrote:
>>> I want to parse this text and count the occurrence of each word:
>>>
>>> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html;
>>> #Can I do this?
>>> $stripping = strip_tags($text); #get rid of html
>>> $stripping = strtolower($stripping); #put in lowercase
>>>
>>> 
>>> First of all I want to start AFTER the expression "News Releases" and stop
>>> BEFORE the next occurrence of "-30-"
>>>
>>> #This may occur an undetermined number of times on
>>> http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>>
>>>
>>> 
>>> Second, do I put $stripping into an array to separate each word by each
>>> space " "?
>>>
>>> $stripping = implode(" ", $stripping);
>>>
>>> 
>>> Third how do I count the number of occurrences of each word?
>>>
>>> Sample Output:
>>>
>>> determined = 4
>>> fire = 7
>>> patrol = 3
>>> theft = 6
>>> witness = 1
>>> witnessed = 1
>>>
>>> 
>>> >> $text = http://www.cegepsherbrooke.qc.ca/~languesmodernes/test/test.html
>>> #echo strip_tags($text);
>>> #echo "\n";
>>> $stripping = strip_tags($text);
>>>
>>> #Get text between "News Releases" and stop before the next occurrence of
>>> "-30-"
>>>
>>> #$stripping = str_replace("\r", " ", $stripping);# getting rid of \r
>>> #$stripping = str_replace("\n", " ", $stripping);# getting rid of \n
>>> #$stripping = str_replace("  ", " ", $stripping);# getting rid of the
>>> occurrences of double spaces
>>>
>>> #$stripping = strtolower($stripping);
>>>
>>> #Where do I go now?
>>> ?>
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>> This is usually a first-year CS programming problem (word frequency
>> counts) complicated a little bit by needing to extract the text.
>> You've started off fine, stripping tags, converting to lower case,
>> you'll want to either convert or strip HTML entities as well, deciding
>> what you want to do with plurals and words like "you're", "Charlie's",
>> "it's", etc, also whether something like RFC822 is a word or not
>> (mixed letters and numbers).
>>
>> When you've arranged all that, splitting on white space is trivial:
>>
>> $words = preg_split('/[[:space:]]+/',$text);
>>
>> and then you just run through the words building an associative array
>> by incrementing the count of each word as the key to the array:
>>
>> foreach ($words as $word) {
>> $freq[$word]++;
>> }
>
> Please an existence check to avoid incrementing not set array keys
>
> foreach ($words as $word) {
>   if (array_key_exists($word, $freq)) {
> $freq[$word] = 1;
>   } else {
> $freq[$word]++;
>   }
> }

Ah, yes, good point -- as written, my code will raise two notices. In
addition, "declare" the $freq array:

$freq=array();

as well before the foreach loop to ensure notice-free operation.

>
>
>>
>> For output, you may want to sort the array:
>>
>> ksort($freq);
>>
>
>
> --
> Marco Behnke
> Dipl. Informatiker (FH), SAE Audio Engineer Diploma
> Zend Certified Engineer PHP 5.3
>
> Tel.: 0174 / 9722336
> e-Mail: ma...@behnke.biz
>
> Softwaretechnik Behnke
> Heinrich-Heine-Str. 7D
> 21218 Seevetal
>
> http://www.behnke.biz
>
>

-- 
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-19 Thread tamouse mailing lists
On Sun, Aug 19, 2012 at 8:28 PM,   wrote:
> http://www.computerworld.com/s/article/9219685/Site_builder_shootout_Drupal_vs._Joomla_vs._WordPress
> Very good article IHMO.
>
>
>> Hi to everyone,
>> I was trying to figure this out for the last week or two. I have read tons
>> of articles that compare Drupal and WordPress, but I still wasn't swayed
>> to either side.
>> I know that they are both good, both do the job well, and both have
>> advantages and disadvantages. For example, Drupal has a steeper learning
>> curve, but you get more control over the website.
>> Most of Drupal vs WordPress articles are "emotionally" driven and it
>> reminds me of the PC vs Apple flame war. I was trying to exclude these as
>> much as I could but it's hard.
>>
>> Is there any website/article/benchmark/test/experiment/whatever I can
>> trust to be unbiased? I need a website that measures the CMS' through
>> facts, not heated, emotional arguments. In which cases is it better to use
>> Drupal over WordPress (and vice-versa)? I know the first two words are
>> going to be "it depends", but let's talk about it in general (for small
>> basic websites, more complex websites, easy customization, etc).
>>
>> I found this on one page: "... Drupal was built as a fine-grained
>> multi-role system where you can assign different permissions to different
>> roles to do different things (e.g. content editor, content reviewer,
>> member, etc.) and assign users to these roles..." Does that mean that
>> WordPress can't do that? Maybe it can, and the quotation is true, but it
>> is kind of misleading to say that one of the programs does something, and
>> then not mention the other product at all.
>>
>> Special points for me are (not a must, though)
>> - multiple websites with single core (both CMSs have the capability but I
>> got impression Drupal does it better?) because of maintenance
>> - compatibility with CiviCRM
>>
>> Once I decide what to use, I have to stick with it for a while.
>>
>> Thanks for any help.
>>
>> LAMP
>>
>>
>> --
>> 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
>

Since both Drupal and Wordpress blather about not needed to know any
programming to use, I'm not much interested. I like wordpress for my
blogs, drupal has never felt compelling when I've delved into it.

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
OT Reply -- just frustrated with the way email screws up program
listings. It's a royal pain to have to strip out code and then put it
in an editor and tidy it up just to be able to make heads or tails out
of something. There are lots of code pasting sites around, but that
breaks up the continuity of the list archive. No solution, just
frustrated

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
On Thu, Aug 23, 2012 at 2:51 PM, admin  wrote:
> Hello everyone,
>
> In my quest to build bigger and better dynamic content, I am
> putting forth a concept to see what you all think.
>
> Many times I come across customers who want drop down menus dynamically
> built from database tables.
>
>
>
> Old way Example:
>
> Echo '--Please  Select--';
>
> $query = "SELECT * FROM personnel ORDER BY last_name";
>
> $result = mysql_query($query);
>
> If(mysql_num_rows($result) >= 1)
>
> {
>
> While($row = mysql_fetch_assoc($result))
>
> {
>
> Echo "".$row['first_name']."
> ".$row['last_name']."";
>
> }
>
> }
>
> Echo '';
>
> *
>
>
>
> I am purposing a Method for this that has some flexibility.
>
>
>
> Initialize Object:  $yourobject = new yourclass();
>
> Call method: // The call design is just so you have a better understanding
> of my concept
>
> $dropdown = $yourobject-> dropmenu('personnell','ID',array(0 =>
> 'first_name', 1 => 'last_name'), 'last_name');
>
>
>
> Function dropmenu($table,$fieldforvalue,$fieldstodisplay,$fieldorder)  //
> Yes you could add some WHERE filters as well
>
> {
>
> $arraytoreturn = array();
>
> If(strlen($table) >= 3){
>
> if(is_array($fieldstodisplay)){
>
> $count = 0;
>
> foreach($fieldstodisplay as $key=>$values){
>
> if(strlen($values) >=3){
>
> If($count == 0){
>
> $fields = $values;
>
> }else{
>
> $fields . = ",".$values;
>
> }
>
> $count++;
>
> }
>
>
> }
>
> }else{
>
> If(strlen(($fieldstodisplay) >= 1){
>
> $fields = $fieldstodisplay;
>
> $fieldstodisplay = array(0
> =>$fieldstodisplay);
>
> }else{
>
> Return $arraytoreturn; // Return nothing
> because no field was selected.
>
> }
>
> }
>
> }else{
>
> Return $arraytoreturn; // Return nothing because no table was selected.
>
> }
>
> If(strlen($fieldorder) >= 3) {
>
> $orderfilter = " ORDER BY ".$fieldorder." ";
>
> }else{
>
> $orderfilter = "";
>
> }
>
> $query = "SELECT ".$fields." FROM ".$table." ".$orderfilter." ";
>
> $result = mysql_query($query);
>
> If(mysql_num_rows($result) >= 1)
>
> {
>
> $arraytoreturn[] = "--Please Select--";
>
> While($row = mysql_fetch_assoc($result))
>
> {
>
> $display_fields   = "";
>
> Foreach($fieldstodisplay as $key=>$values){
>
> $display_fields  .= $row[$values]." ";
>
> }
>
> If(strlen($fieldforvalue >= 3){
>
> $arraytoreturn[] = " value='".$row[$fieldforvalue]."'>".$display_fields  ."";
>
> }else{
>
> $arraytoreturn[] = "".$display_fields  ."";
>
> }
>
> }
>
> Return $arraytoreturn;
>
> }else{
>
> Return $arraytoreturn; // Nothing to return.
>
> }
>
> }
>
>
>
> Now I can call the drop downs driven by database tables dynamically and It
> saves me a TON of time.
>
> Echo '';
>
> Foreach($dropdown as $key=>$values){
>
> Echo $values;
>
> }
>
> Echo '';
>
>
>
>
>
> Richard L. Buskirk
>
> "Some of the world's greatest feats were accomplished by people not smart
> enough to know they were impossible"

Some things you may want to consider in extending this:

* The separation of code and data is important to consider; this sort
of function, for me, falls into the grey area in between; I often have
built up the array of options and other elements of the  and
then have passed it onto the portion of the app that handles views,
keeping any sort of HTML out of the way of the database queries, etc.
Encapsulating this in a single class brings up the issues of data base
agnosticism as well.

* Often times, on a form, one may want to include a  for the
select statement.

* At some point, you may want to use the "selected" attribute in one
of the options.

My HTML selects typically have the following form:

Select the appropriate item:

  Item One
  Item Two


The code I use that generates this is at http://pastebin.com/SZYN5qgv

The call would be something like:

echo dynamic_select(array('opt1'=>'Item One','opt2'=>'Item
Two'),'dyn_select','Select the appropriate item:','opt2');

The first parameter can obviously be an array created from a database
query using whatever database methods you'd like: mysql, mysqli, pg_*,
PDO, etc.

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
On Fri, Aug 24, 2012 at 10:11 AM, Samuel Lopes Grigolato
 wrote:
> Do you mean the ">" quotation marks? Have you tried to create a simple 
> Notepad++ macro? I do this for things like formatting SQL from SQL Editor to 
> SQL String in code, and vice versa.

No, I mean the way the code is mangled with premature line breaks, bad
indenting, and other such things. As I tend to view my email via a
webmail interface (sucks, but there I am) it is subject to whatever
whims and fancies of the originator's program and gmail's output.

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
On Fri, Aug 24, 2012 at 10:16 AM, Jim Lucas  wrote:
> On 08/24/2012 08:01 AM, tamouse mailing lists wrote:
>>
>> OT Reply -- just frustrated with the way email screws up program
>> listings. It's a royal pain to have to strip out code and then put it
>> in an editor and tidy it up just to be able to make heads or tails out
>> of something. There are lots of code pasting sites around, but that
>> breaks up the continuity of the list archive. No solution, just
>> frustrated
>>
>
> This list does allow attachments, but that breaks things too, because they
> are not shown on archive web sites.

Wow, I did not know it even allowed attachments.

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
On Fri, Aug 24, 2012 at 10:47 AM, Matijn Woudt  wrote:
> On Fri, Aug 24, 2012 at 5:33 PM, Jim Lucas  wrote:
>> On 08/24/2012 08:25 AM, Matijn Woudt wrote:
>>>
>>> On Fri, Aug 24, 2012 at 5:22 PM, Jim Lucas  wrote:

 Two simple guide lines will help everybody here.

 1) Limit your lines to 80 characters
 2) Use spaces instead of Tabs

>>>
>>> Are we going to discuss coding guidelines again? The 80-character
>>> limit is outdated, 100 or 120 is more common today.
>>> And while I do agree with the spaces, do you also insist on 2, 4 or ..
>>> spaces? ;)
>>> Oh and I'd like everybody to put the opening brackets on the same line..
>>> bla bla
>>>
>>> My point is: It's not going to happen.
>>>
>>> - Matijn
>>
>>
>> This has absolutely nothing to do with your own personal coding styles.
>> This has only to do with how you are going to present code to the list
>> members.
>
> So you expect people to convert all their code to a 'mailing list
> standard' before posting? Still not going to see that happen..
>
>>
>> Personally, I let my code ramble on as long a line as it needs.  I use tabs
>> (set to 8 chars) in my code.  That is because the other developers that I
>> work with have editors that can display the tabs in whatever width they
>> desire.  I also do not wrap at 80 chars.
>>
>> But if you look back at any of my code examples that I have written, none of
>> them are longer then 80 characters, and uses two spaces for indentation.
>> Simply because my email client is set to plain text and wraps at 80 chars.
>
> I can see that you do that indeed, but that does *not* guarantee that
> it is also seen that way. I think most of us use a 'smart' mail
> client, that automatically makes emails more readable by undoing these
> stupid line breaks at 80 chars. Gmail for example shows your mail as
> lines with approx 175 chars on my 17" notebook.. I'm not sure how
> Gmail sends my messages, but looking at the 'Show original' option, it
> seems it breaks long lines but might be at a different length too.

See, now this is what gets me. Gmail is folding my mail at some
indeterminant length that seems *much* shorter than even 80
characters, but it willingly lets email from non-gmail sources play
across the page as they see fit. I don't see why Gmail doesn't just
make it a QP item and not force line breaks upon me.

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
On Fri, Aug 24, 2012 at 10:12 AM, Matijn Woudt  wrote:
> On Fri, Aug 24, 2012 at 5:01 PM, tamouse mailing lists
>  wrote:
>> OT Reply -- just frustrated with the way email screws up program
>> listings. It's a royal pain to have to strip out code and then put it
>> in an editor and tidy it up just to be able to make heads or tails out
>> of something. There are lots of code pasting sites around, but that
>> breaks up the continuity of the list archive. No solution, just
>> frustrated
>
> You're absolutely right, it frustrates me too pretty often. Perhaps we
> should make it a guideline to do both? The active followers will be
> able to read the code at one of the code pasting sites, and the
> archives still have the code.
>
> - Matijn

I'm wondering if it might make sense to have a code-pasting site
specifically for PHP lists? Is that asking too much?

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
On Fri, Aug 24, 2012 at 10:20 AM, David OBrien  wrote:
> In gmail if I see something is totally screwed up visually I click the
> little dropdown where you'd select reply to all and then choose show
> original...
> It shows the source of the email in monospaced font so if looks like it was
> meant to

*Sometimes* that works. If you do that with the sample from the OP, it
still has several indentation/alignment issues.

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



Re: [PHP] Dynamic Content thoughts

2012-08-24 Thread tamouse mailing lists
On Fri, Aug 24, 2012 at 1:24 PM, Jim Lucas  wrote:
> Well, not to talk bad about Gmail (I use it for personal accounts), but I
> like using a client that I do have some control over what it does to my
> email.  Making sure that it retains my formatting is one of my first
> requirements.

I'd like that as well, however, I access my various gmail and other
email accounts from so many different machines, I can't rely on any
one particular client or even machine. Thus, I'm pretty much stuck
with the web interface.

FWIW, I am pretty sure sending out email from a standard client to a
gmail account doesn't suffer the same issues.

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



Re: [PHP] UTC on php log bug

2012-08-26 Thread tamouse mailing lists
On Fri, Aug 24, 2012 at 8:48 PM, Martín Marqués
 wrote:
> Whats up with this bug?: https://bugs.php.net/bug.php?id=60723

perhaps direct the query (such as it is) to php-development

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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread tamouse mailing lists
On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan
 wrote:
> On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote:
>
>> Can you tell us what is the error shown in browser or CLI?
>>
>> On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
>> wrote:
>>
>> > I've just inherited some (pretty awful code) that I have to make some
>> > edits to, and came across a bit of a problem. A lot of the code breaks
>> > in and out of PHP and into HTML code:
>> >
>> >  > > while(condition)
>> > {
>> > ?>
>> > some html here
>> > > > }
>> > ?>
>> >
>> > But when I check this my PHP parser is saying that this is a syntax
>> > error (checked in the browser and CLI). I know this is code from a
>> > working site, so it must be a setting within my PHP configuration.
>> >
>> > Now, I'm intending to re-write this anyway, as the logic is all over the
>> > place (SQL queries within the HTML, no separation of code and content,
>> > dozens of warnings all over the place) but I was wondering what setting
>> > causes this. It's mostly a curiosity thing really, as this thing is
>> > going to be re-written faster than an school project the eve before
>> > hand-in.
>> >
>> > --
>> > Thanks,
>> > Ash
>> > http://www.ashleysheridan.co.uk
>> >
>> >
>> >
>>
>>
>
>
> Through the browser I get:
>
> Parse error: syntax error, unexpected $end
> in /var/www/html/siteinquestion/index.php on line 356
>
> Through the CLI I get:
>
> PHP Parse error:  syntax error, unexpected $end in index.php on line 356
>
> Parse error: syntax error, unexpected $end in index.php on line 356
>
> Errors parsing index.php
>
> I've narrowed it down to the lines that used the breaking in and out of
> PHP style. As soon as I comment out those it runs fine, albeit without
> the content that code was intended to add.
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

I guess I would suspect errant spaces, or a missing closing tag, or
even maybe a short code or something... very hard to say...

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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread tamouse mailing lists
On Sun, Aug 26, 2012 at 5:02 AM, Ashley Sheridan
 wrote:
>
> On Sun, 2012-08-26 at 04:36 -0500, tamouse mailing lists wrote:
>
> On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan
>  wrote:
> > On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote:
> >
> >> Can you tell us what is the error shown in browser or CLI?
> >>
> >> On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
> >> wrote:
> >>
> >> > I've just inherited some (pretty awful code) that I have to make some
> >> > edits to, and came across a bit of a problem. A lot of the code
> >> > breaks
> >> > in and out of PHP and into HTML code:
> >> >
> >> >   >> > while(condition)
> >> > {
> >> > ?>
> >> > some html here
> >> >  >> > }
> >> > ?>
> >> >
> >> > But when I check this my PHP parser is saying that this is a syntax
> >> > error (checked in the browser and CLI). I know this is code from a
> >> > working site, so it must be a setting within my PHP configuration.
> >> >
> >> > Now, I'm intending to re-write this anyway, as the logic is all over
> >> > the
> >> > place (SQL queries within the HTML, no separation of code and
> >> > content,
> >> > dozens of warnings all over the place) but I was wondering what
> >> > setting
> >> > causes this. It's mostly a curiosity thing really, as this thing is
> >> > going to be re-written faster than an school project the eve before
> >> > hand-in.
> >> >
> >> > --
> >> > Thanks,
> >> > Ash
> >> > http://www.ashleysheridan.co.uk
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
> > Through the browser I get:
> >
> > Parse error: syntax error, unexpected $end
> > in /var/www/html/siteinquestion/index.php on line 356
> >
> > Through the CLI I get:
> >
> > PHP Parse error:  syntax error, unexpected $end in index.php on line 356
> >
> > Parse error: syntax error, unexpected $end in index.php on line 356
> >
> > Errors parsing index.php
> >
> > I've narrowed it down to the lines that used the breaking in and out of
> > PHP style. As soon as I comment out those it runs fine, albeit without
> > the content that code was intended to add.
> >
> > --
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
>
> I guess I would suspect errant spaces, or a missing closing tag, or
> even maybe a short code or something... very hard to say...
>
>
> None of the above. This is a working copy of code. It's just to do with
> these lines breaking in and out of PHP.


Byte encodings? Line endings? Sorry, I'm sure you've thought of all this..

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



Re: [PHP] multiple forms one page

2012-08-26 Thread tamouse mailing lists
On Sun, Aug 26, 2012 at 11:08 PM, Rosie Williams
 wrote:
>
> Hi all,
> I am a newbie to PHP. I have several php forms which were originally on 
> separate pages now included in the one page. Each form had the following code 
> in it:
> function mysql_fix_string($string){ if (get_magic_quotes_gpc()) $string = 
> stripslashes($string);return mysql_real_escape_string($string);}
> function mysql_entities_fix_string($string){return 
> htmlentities(mysql_fix_string($string));}
> However I am only able to include it in one of the forms on the new page with 
> multiple scripts due to the fatal error that I can only declare the function 
> once. So for testing I have commented these lines out of the other scripts. I 
> need to know what the security implications of this are? Do the scripts that 
> do not contain these lines run without it or is it included automatically 
> every time the database is accessed regardless of which script is accessing 
> it?
> If not how do I deal with it?
> thanks in advanceRosie

Hi, Rosie, welcome!

This is something you will likely encounter again, so it is good to
learn it now.

You can put the two functions into another php file, and include that
file in your main script using include_once or require_once (there is
a difference that you might want to read up on at some point). If you
include this before you start your form processing, the functions will
be available to you at the point you need them. You only need do this
once in the php script where you will be using them, so you can safely
delete all the other occurances of the function definitions.

The nice part is, really, that you can use that same include file in
other projects as you go along, saving retyping the code. This is
something that you may want to think about for other such functions as
well. Modularity and code reuse are one of the big ways to achieving
more efficiency in your work.

http://us.php.net/manual/en/function.include-once.php
http://us.php.net/manual/en/function.require-once.php
(cf. http://us.php.net/manual/en/function.require.php to learn how the
"require" differs from the "include")


Best of luck,

Tamara
   aka tamouse__

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



Re: [PHP] include selectively or globally?

2012-08-27 Thread tamouse mailing lists
What do your performance measurements show so you have actual data
comparisons to make a valid decsion?

-- 
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-29 Thread tamouse mailing lists
On Tue, Aug 28, 2012 at 3:36 PM, Adam Richardson  wrote:
> On Tue, Aug 28, 2012 at 3:07 PM, Larry Garfield  
> wrote:
>> Only semi-joking line that's been making the rounds lately:
>>
>> If you want to build a blog, use Wordpress.
>> If you want to build Wordpress, use Drupal.
>> If you want to build Drupal, use Symfony2.
>
> Here's another semi-joking line :)
>
> If build a blog using Wordpress, build Wordpress using Drupal, build a
> Drupal using Symfony2, I'd feel the same way I feel after drinking
> several beers, eating a pizza, snacking on some hot wings, and
> polishing it all off with a banana split: bloated :)
>
> Adam
>
> --
> Nephtali:  A simple, flexible, fast, and security-focused PHP framework
> http://nephtaliproject.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Is that the analog to Sagan's "how to make an apple pie" ?

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



Re: [PHP] extract Occurrences AFTER ... and before "-30-"

2012-09-02 Thread tamouse mailing lists
On Sun, Sep 2, 2012 at 11:31 AM, John Taylor-Johnston
 wrote:
> I'll never get it. Newest work on top of the pile, instead of digging :))

Usually order reverse in flow conversations your do?

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



Re: [PHP] extract Occurrences AFTER ... and before "-30-"

2012-09-02 Thread tamouse mailing lists
On Sun, Sep 2, 2012 at 7:57 PM, John Taylor-Johnston
 wrote:
> Just to prove me right, our mail clients start quoting from the top too :)p

Exactly. The quoting starts from the *top*. The problem is that the
cursor to start typing is also put there by default.
Step back before MS Outlook started that trend, which, of course, one
could *change* if one wanted to. The standard proforma for mail,
usenet, notes, bbs's, and most other forms (c.f. the Well, etc) were
all bottom post, or even better intermingled with ONLY the relevant
parts used, not the entire message.

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



Re: [PHP] load rtf file

2012-09-02 Thread tamouse mailing lists
On Mon, Sep 3, 2012 at 12:23 AM, John Taylor-Johnston
 wrote:
> I have a big giant RTF file. I could convert it to plain text. BUT can PHP
> do it for me?

Not directly, although there might be libraries out there to do it,
but none that I'm aware of off-hand. Perl, of course does this with
RTF::TEXT::Converter <
http://search.cpan.org/~sargie/RTF-Parser-1.09/lib/RTF/TEXT/Converter.pm
>. To use this, you'd have to hand off the processing to a perl script
using shell_exec, proc_open, etc.

> I want to read the text file into a string. This does the job well, right?
> http://php.net/manual/en/function.file-get-contents.php
>
> This is it? Not more complicated?
>
> | $homepage = file_get_contents('http://www.example.com/text.txt');
> echo $homepage;
> ?> |

Not really complicated, *however* there is a php.ini option that must
be set for this to work: <
http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
>

> What about this?
> http://www.php.net/manual/en/function.file.php
>
> || |$lines = file('http://www.example.com/');|
> |echo $lines;
> ?>|
>
> Is there any big difference?

*HUGE* difference:

* file_get_contents returns a single *string* with the entire content.
* file returns an *array* of lines.

Change your above snippets to use 'var_dump($lines);' instead of 'echo
$lines;' to see the structural difference.

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



Re: [PHP] load rtf file

2012-09-03 Thread tamouse mailing lists
On Mon, Sep 3, 2012 at 6:04 PM, Micky Hulse  wrote:
> On Mon, Sep 3, 2012 at 3:52 PM, Tedd Sperling  wrote:
>> Maybe if I was on a Windoze machine, but I'm on a Mac.
>
> What about TextEdit.app?

Or Open/Libre Office?

As for the OP, I know you can script Open/Libre Office with python to
do things like batch convert RTF to Text.

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



Re: [PHP] templeting

2012-09-03 Thread tamouse mailing lists
On Mon, Sep 3, 2012 at 8:49 PM, David McGlone  wrote:
> On Monday, September 03, 2012 09:45:23 PM David OBrien wrote:
>> On Sep 3, 2012 9:15 PM, "David McGlone"  wrote:
>> > Does anyone use any templeting system for any projects? If so what would
>> > anyone recommend? I looked at Code Ignitor, but it seems the templeting
>>
>> system is optional and left out by default.
>
>> I use smarty
>
> I've used smarty in the past and was thinking about that, but PEAR is absolete
> anymore and I don't really know of a good replacement. :-/

I use Smarty as well, but I've never used it from PEAR. I just use the
version downloadable from http://www.smarty.net

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



Re: [PHP] How to limit source IP in PHP

2012-09-13 Thread tamouse mailing lists
Are you looking to use sockets? That's the only thing I can think of
when you speak of binding to an ip address/port...

http://php.net/manual/en/book.sockets.php ?

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



[PHP] Fwd: [PHP-DB] Prepared Statements - Search

2012-09-13 Thread tamouse mailing lists
Crud, forgot to include list.


-- Forwarded message --
From: tamouse mailing lists 
Date: Thu, Sep 13, 2012 at 10:31 PM
Subject: Re: [PHP-DB] Prepared Statements - Search
To: erosenb...@hygeiabiomedical.com


On Thu, Sep 13, 2012 at 7:09 PM, Ethan Rosenberg, PhD
 wrote:
> Dear List -
>
> Here is another problem I am having with prepared statements.  The last one
> was  INSERT, this one is SELECT.
>
> Here is the database:
>
> mysql> describe Intake3;
> ++-+--+-+-+---+
> | Field  | Type| Null | Key | Default | Extra |
> ++-+--+-+-+---+
> | Site   | varchar(6)  | NO   | PRI | |   |
> | MedRec | int(6)  | NO   | PRI | NULL|   |
> | Fname  | varchar(15) | YES  | | NULL|   |
> | Lname  | varchar(30) | YES  | | NULL|   |
> | Phone  | varchar(30) | YES  | | NULL|   |
> | Height | int(4)  | YES  | | NULL|   |
> | Sex| char(7) | YES  | | NULL|   |
> | Hx | text| YES  | | NULL|   |
> | Bday   | date| YES  | | NULL|   |
> | Age| int(3)  | YES  | | NULL|   |
> ++-+--+-+-+---+
> 10 rows in set (0.00 sec)
>
> Here is my code:
>
> // Prepare statement
> $stmt = mysqli_stmt_init($cxn);
> $sql11 = "SELECT  'Fname', 'Lname', 'Phone', Height, Hx, Bday, Age FROM
> Intake3 where 1 and (MedRec = ?) and (Site = ?) and (Sex = ?)";
> // Allocates and initializes a statement object suitable for
> mysqli_stmt_prepare().
> // Prepare statement, bind result variables, execute and place results into
> bound result variables
>mysqli_stmt_prepare($stmt, $sql11);
>mysqli_stmt_execute($stmt);
>mysqli_stmt_bind_result($stmt, $Site, $MedRec, $Fname, $Lname, $Phone,
> $Height, $Sex, $Hx, $Bday, $Age); //The error is in this statement.
> while (mysqli_stmt_fetch($stmt)) {
> printf("%s %s %s %s %s %s %s %s %s %s \n", $Site, $MedRec, $Fname,
> $Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age);
> }
>
> I get no output from the printf statement.
>
> I receive the following error:
>
> Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match
> number of fields in prepared statement.
>
> The query, with the values inserted, works on the command line
>
> Help and advice, please.

Pay attention to the code you write.

Your SQL SELECT Statement pulls in these fields, in this order:

'Fname'
'Lname'
'Phone'
Height
Hx
Bday
Age

Got that?

Your bind statement binds the following variables:

$Site
$MedRec
$Fname
$Lname
$Phone
$Height
$Sex
$Hx
$Bday
$Age

So, pairing those up, this is the relationship the bind statement sees:

Column -> PHP variable
--
'Fname' -> $Site
'Lname' -> $MedRec
'Phone' -> $Fname
Height -> $Lname
Hx -> $Phone
Bday -> $Height
Age -> $Sex

and oops, out of columns to bind to the remaining items:

??? -> $Hx
??? -> $Bday
??? -> $Age

So, lesson is: the bind results statement must match exactly
one-for-one with each column returned in the SELECT statement.

Additionally, I'm really uncertain the effect of the surrounding
single quotes on 'Fname', 'Lname' and 'Phone' in your SELECT
statement; perhaps they don't matter, but I've never seen that. Column
names such as you show do not need to be quoted, as none of them
represent MySQL key/reserved words, and when you do quote field names
in MySQL, you use the backtick, i.e. "`", not a single quote.

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



Re: [PHP] PHP Threading on Windows

2012-09-13 Thread tamouse mailing lists
On Thu, Sep 13, 2012 at 9:32 PM, admin  wrote:
> It has been suggested:
> That because php does not support PCNTL threading on Windows that
> multiple services of php are an alternative.
>
> I am interested in this theory, if anyone is currently working on a project
> that (forks) processes off to another instance or service of PHP on windows
> please let me know.
> In some of my latest development I have some rather large processes that
> consume the single instance of PHP, threading these off would be ideal.
>
> Example:
> $tmpsrv=win32_query =win32_create_service(array(
> 'params' => __FILE__." install",
> 'service' => 'Name_of_the_service',
> 'display' => 'Name of service to be displayed in the service list'
> ));
>
> Any windows php developers have ideas, comments on this suggestion?

I'm interested in the answer to this as well.

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



Re: [PHP] bucle while for to msqyl

2012-09-16 Thread tamouse mailing lists
On Sun, Sep 16, 2012 at 5:08 PM, El Ale...  wrote:
> 
> $conexion = mysql_connect("localhost", "usuario", "123456");
> mysql_select_db("probando", $conexion);
>
> function updateNumero() {
>
> $queEmp = "SELECT n FROM numero WHERE n LIKE 1";
> $resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
> $totEmp = mysql_num_rows($resEmp);
> if ($totEmp> 0) {
>  while ($rowEmp = mysql_fetch_assoc($resEmp)) {
> $numero = $rowEmp['n'];
> }
> }
> return $numero;
> }
> ?>
>
> in this way?
>
> I do not understand is where the loop would do, what I need to remember is
> that if it is "true" to repeat the condition and if false stops.
>
> Thanks!
>
> 2012/9/16 Serge Fonville 
>
>> If you wrap the query inside your while loop at the point where you want
>>> to check for a change of the value it will change at every iteration.
>>
>>
>> For ease of use, it would be better to create  a function around the data
>> gathering part, i.e.
>>
>>> function updateNumero() {
>>>
>>> $queEmp = "SELECT n FROM numero WHERE n LIKE 1";
>>> $resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
>>>  $totEmp = mysql_num_rows($resEmp);
>>> if ($totEmp> 0) {
>>>  while ($rowEmp = mysql_fetch_assoc($resEmp)) {
>>>  $numero = $rowEmp['n'];
>>> }
>>> }
>>>  return $numero;
>>> }
>>
>>
>> Kind regards/met vriendelijke groet,
>>
>> Serge Fonville
>>
>> http://www.sergefonville.nl
>>
>> Convince Microsoft!
>> They need to add TRUNCATE PARTITION in SQL Server
>>
>> https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
>>
>>
>>
>> 2012/9/16 El Ale... 
>>
>>> How could I?, should use another command? I need to do that if the value
>>> of the script is the same as the database and repeat but stops.
>>>
>>> greetings!
>>>
>>>
>>> 2012/9/16 Serge Fonville 
>>>
 Since the value is never changed inside the loop, it will run
 indefintely or stop immediately.

 You need to re-request the value from the database to change $numero to
 a possible other value.

 Kind regards/met vriendelijke groet,

 Serge Fonville

 http://www.sergefonville.nl

 Convince Microsoft!
 They need to add TRUNCATE PARTITION in SQL Server

 https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table



 2012/9/16 El Ale... 

> yes it 1 = 1 its (true) bucle's run, but! if 1 is not same  1 bucle
> break.
> when consulted database and this value is 1, the loop continues, but
> when changing the value of the database for example "value 2", the loop
> should stop because 1 is not equal to 2 but not Doing so ignores it and
> segue running as if the value is one, that's the problem
>
> Thank you!
>
>
> 2012/9/16 Serge Fonville 
>
>> Also, if $numero equals 1, it always prints 1.
>> Is that the expected behaviour?
>>
>> When it does not match 1, it does nothing except it echos 1 twice,
>> first in the  conexion.php and second in the first iteration of the
>> while loop
>>
>> Kind regards/met vriendelijke groet,
>>
>> Serge Fonville
>>
>> http://www.sergefonville.nl
>>
>> Convince Microsoft!
>> They need to add TRUNCATE PARTITION in SQL Server
>>
>> https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
>>
>>
>>
>> 2012/9/16 El Ale... 
>>
>>>
>>>
>>> 2012/9/16 El Ale... 
>>>
>>> Im sorry "reset;" is not, this is:

 >>> include("conexion.php");

 do {


 echo "$numero";
 sleep(1);


 if ($numero == 1)

 continue;
 break;
 } while (true);

 ?>

 Thanks!


 2012/9/16 Serge Fonville 

> Hi,
>
> if ($numero == 1)
>> reset;
>> continue;
>> break;
>> } while (true);
>
>
> If the $numero is equal to 1 reset seems odd
> reset is a function.and requires an array
> Based on your code, this would run indefintely
> Since there are no braces after the if statement, only the first
> statement is executed when $numero equals 1
>
> Also, is this your actual code?
>
> If not and possible please add that
>
> HTH
>
> Kind regards/met vriendelijke groet,
>
> Serge Fonville
>
> http://www.sergefonville.nl
>
> Convince Microsoft!
> They need to add TRUNCATE PARTITION in SQL Server
>
> https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
>
>
>
> 2012/9/16 El Ale... 
>

Re: [PHP] Re: PHP Bounce messages

2012-09-21 Thread tamouse mailing lists
On Fri, Sep 21, 2012 at 4:17 AM, Tim Streater  wrote:
> On 21 Sep 2012 at 08:40, Lester Caine  wrote:
>
>> I know that the php list are one of the 'reply to sender' email handling camp
>> rather than reply to list.
>
> I don't understand this. I reply (not that I mail that often) just to the 
> list, if possible. Why would I do anything else?

I believe Lester is referring to the behaviour of the Reply-To: field
sent by the list serv, which is the sender's address. Some other
listservs put the list reply address in Reply-To:

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



Re: [PHP] Day after Friday

2012-09-23 Thread tamouse mailing lists
On Sun, Sep 23, 2012 at 8:33 AM, Tedd Sperling  wrote:
> On Sep 22, 2012, at 3:59 PM, Paul M Foster  wrote:
>> On Sat, Sep 22, 2012 at 01:05:51PM -0400, Tedd Sperling wrote:
>>
>>> Hi gang:
>>>
>>> I know it's the Day after Friday, but I'm asking a off-topic question 
>>> anyway -- sorry.
>>>
>>> Normally, I teach a PHP class at the local college, but it got canceled 
>>> (don't ask why) -- now I'm teaching Java.
>>>
>>> So, can anyone recommend a Java list that is similar to this list?
>>
>> Off off topic...
>>
>> Who the hell cancels a PHP class? Do they not realize damn near the
>> whole internet runs on PHP? Wordpress, Drupal, Joomla, Facebook ad
>> nauseum, not to mention Symfony, CakePHP, Code Igniter, etc.
>> Administrators! Ach!
>>
>> Paul
>
> Paul:
>
> The class was canceled by administration and they have absolutely no 
> conception of the technology and scope that PHP brings to the table. In fact, 
> they were so opposed to PHP that when I first started teaching there they had 
> PHP removed from their servers because of security concerns. So, for me to 
> teach PHP, they were forced to install PHP/MySQL.
>
> Now that you asked, here's the story about my PHP class.
>
> The college moved the entire CIT (Computer Information Technology) department 
> five miles from the downtown campus, where it has always been, to the new 
> West campus. It's a nice campus, but no Macs -- admin said Mac don't meet 
> their ROI requirement, but that's another story.
>
> Of course, most students don't have transportation and there is no 
> established public transportation from main campus to west campus -- that's 
> not good.
>
> Knowing that the students were going to have problems with transportation and 
> that would result in a reduction in class sizes, the administration agreed to 
> allow "smaller than norma"l classes for the Fall semester. Furthermore, the 
> administration agreed to allow registration to be for a longer period than 
> normal, namely from a couple of weeks before the semester started to a week 
> after the semester started.
>
> Everything sounds ok, right?
>
> My PHP class had six students register two weeks before the class started. I 
> expected, as is custom, to pick up a couple of students after the semester 
> started thus exceeding the minimum number of student required. Furthermore, I 
> agreed to teach the class at a reduced rate if there wasn't a sufficient 
> number of students attending. BTW, administration had not made a 
> determination as to exactly what the minimum class-size should be -- keep in 
> mind, they only had two years to decide and these things take time.
>
> So what happened?
>
> Well we (the teachers) have a new contract and in that contract is a 
> provision that allows for a reduced class size IF the teacher agrees to teach 
> it at a reduced rate -- which I agreed to do. However, administration became 
> confused as to how to pay a full time teacher IF they taught an undersized 
> class. So, their solution was to cancel ALL under sized classes before the 
> semester started. That way there would be no confusion as to what to pay.
>
> Now, in my case I am the only teacher to teaches PHP, so there would be no 
> full time teacher that might teach it. I am also an adjunct (part time) 
> teacher and as such there is no confusion as to my pay. I am simply paid 
> hourly and a reduced class size would result in my rate being reduced. So, 
> there was absolutely no reason what-so-ever for my class to be cancelled. 
> Leaps and bounds of illogic.
>
> This is just another example of how administration makes decisions. It would 
> be nice if administration decisions were made with respect to "what is best 
> for the student" as compared to this type of nonsense.
>
> Cheers,
>
> tedd
>
> _
> t...@sperling.com
> http://sperling.com


Oh, Administrators!! The bane of teachers everywhere. The anti-teacher.

Maybe you could slip a little PHP in on the Java kids... :)

Unfortunately, I have no Java list resources...

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



Re: [PHP] Joining a team, where no wiki or docs are available

2012-09-24 Thread tamouse mailing lists
On Mon, Sep 24, 2012 at 5:07 PM, Daevid Vincent  wrote:
> That is a good point. We do not do unit tests here. Nothing against them, 
> it’s just a bit overkill for our needs. We build lots of websites, not one 
> massive SaaS.
>
> But I’m not saying do not use OOP. I’m just saying not everything has to be 
> OOP. It’s a subtle but significant difference.
> We have OOP classes for our database connection (and of course the helper 
> routines), memecache access/purging/etc., and then objects for actors, 
> movies, scenes, search results, HTML templates, email, tickets, etc…  again, 
> use the right tool for the job. When all you have is a hammer, everything is 
> a nail. Build a toolbox. ;-)
>
> From: AmirBehzad Eslami [mailto:behzad.esl...@gmail.com]
> Sent: Monday, September 24, 2012 12:47 PM
> To: Daevid Vincent
> Cc: PHP General Mailing List
> Subject: Re: [PHP] Joining a team, where no wiki or docs are available
>
> Wow. David. That was a great help with every detail !
> Thanks for sharing that with us.
>
> One side question:
> Without OOP, how do you handle Unit Tests?
> Do you know a Testing framework for procedural code?

Wait, what? Unit testing has been around longer than OOP There
weren't the nifty frameworks that make unit testing classes so much
fun today, but you know you can *still* use them on procedural code.

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



Re: [PHP] Vulnerability Announced in phpMyAdmin

2012-09-25 Thread tamouse mailing lists
On Tue, Sep 25, 2012 at 3:20 PM, Daniel Brown  wrote:
> Just a three-list cross-post to bring it to everyone's attention
> at once, in case you weren't already aware.  It was announced today
> that a compromised SourceForge mirror was distributing a malicious
> file with the phpMyAdmin package that allows an attacker to
> arbitrarily execute code on a server hosting the exploitable package.
> Obligatory (not intentionally self-serving) social media link here:
>
> https://twitter.com/oidk/status/250688002005811200
>

Signal boosting...

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



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

2012-09-26 Thread tamouse mailing lists
Crikey, forgot to include the list.


-- Forwarded message --
From: tamouse mailing lists 
Date: Wed, Sep 26, 2012 at 1:57 AM
Subject: Re: [PHP] output compression when host has disabled
mod_deflate, mod_gzip and php_value auto_prepend_file
To: edward eric pedersson 


On Fri, Sep 21, 2012 at 9:50 AM, edward eric pedersson
 wrote:
> I want to compress the css and javascript external files as well but
> without the apache options available I am wondering what other options
> I have. The files are not massive, all but one less than 20k. Not sure
> how much of a performance gain I will get but I thought it is worth
> while asking the question.
>
> One solution I have on my mind is to call a php script that pulls in
> the css and js files and compresses the output e.g

You need to ensure that the browser you are sending to has the
capability to accept compressed input streams as well. Some don't
still, including some screen readers. This may not be as huge a
consideration with CSS or JS, but should still be considered, I think.

>  href="http://my.domain.com/stylesheet.php?file=/path/to/stylesheet.css";
> />
>
> stylesheet.php
> --
> 
>// initialize ob_gzhandler function to send and compress data
>ob_start ("ob_gzhandler");
>
>// send the requisite header information and character set
>header ("content-type: text/css; charset: UTF-8");
>
>// check cached credentials and reprocess accordingly
>header ("cache-control: must-revalidate");
>
>// set variable for duration of cached content
>$offset = 60 * 60;
>
>// set variable specifying format of expiration header
>$expire = "expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " 
> GMT";

I am pretty sure the header needs to be capitalized: "Expires:". Also,
you can simplify the format string a bit:

 $expire = "Expires: " . gmdate (DATE_RFC1123, time() + $offset);

as that is the standard form the Expires header takes.

>
>// send cache expiration header to the client broswer
>header ($expire);
>
>//read and echo the file
>$file = readfile($_GET["file"]);

You want to be careful here and validate that you are sending a real
file that contains what *you* want to send. *Always* untaint input.

>
>echo $file;
>
> ?>
>
> --
>
> Similar code for javascript with different content-type.
>
>
> A few questions:
>
> 1) Will apache cache the full url or the url minus the query parameter?

Generally, it will cache the full url.

> 2) Are there any performance benefits as there is an overhead in
> calling the PHP file?

This entirely depends on the size of the file. If your css or js is
small (<1000 bytes, maybe?) it's not going to be worthwhile. You say
yours are mostly > 2, so it might very well be worthwhile. Also,
it sort of depends on how heavily your server is loaded. Live
performance tests would probably be worthwhile to guage your
particular implementation.

> 3) If the PHP call is cached is it cached with the file query parameter?

Is this a different question than #1?

Something similar was discussed previously, only in the realm of
someone wanting to serve static pages. You can cache the compressed
version of the file and serve if up if it is newer than the
uncompressed version, which might also speed things up, although
probably not a great deal in this case since there's basically no PHP
processing happening here.

p.s. - somehow the OM wound up in my SPAM folder so I didn't see it
for a few days.

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



Re: [PHP] Responding to an XML data post

2012-09-27 Thread tamouse mailing lists
On Thu, Sep 27, 2012 at 1:00 PM, Daniel Brown  wrote:
> On Thu, Sep 27, 2012 at 1:48 PM, Bastien Koert  wrote:
>> Hi All,
>>
>> I am stuck in something where a 3rd party app pushes an XML post to my
>> site. They need me to respond to that push with a synchronous XML post
>> back confirming that the data was received / had issues etc. Those
>> XMLs are defined, but I am not sure how to push that XML back. A
>> simple
>>
>> echo $xml;
>>
>> is not making back to their system. Not sure how I can post back to their 
>> site
>
> If it's an actual postback, they should've given you an API
> endpoint for you to do a cURL post back to their side.  If not, and
> they're just expecting an XML response, it could be that your XML is
> improperly formatted.
>
> --
> 
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Also, make sure you've set the right content type header.

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



Re: [PHP] generate a thumbnail with imagick and place a logo on top

2012-10-03 Thread tamouse mailing lists
On Wed, Oct 3, 2012 at 10:54 AM, A Freund  wrote:
> Hello,
>
> I have a problem creating thumbnails with imagick. The code is working
> ok and the thumbnail is generated in the right size etc but when I try
> to place a PDF logo on the thumbnail it turns half transparent. I guess
> it has something to do with that the PDF file is generated in InDesign
> and probably hasn't any background defined. Has anyone come across this
> problem or has an idea what to do about it? I tried to put a white
> canvas in the background but that didn't help. I also specified a
> channel for the compositeImage function but that didn't help either.
>
> This is the PDF file I'm having issues with:
> https://dl.dropbox.com/u/13712643/Case_Study.pdf
> 
> The generated Thumbnail looks like this:
> https://dl.dropbox.com/u/13712643/Case_Study1.jpg
> 
>
> The code I have produced so far: http://pastebin.com/74CYC972
> 
>
> Thank you for your help.
>
> All the best,
> Andreas

Have you tried replicating what your code is doing with convert? This
doesn't sound like a PHP issue.

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



Re: [PHP] Differences

2012-10-03 Thread tamouse mailing lists
On Wed, Oct 3, 2012 at 9:01 PM, James  wrote:
> All of the images are displaying because you're simply instructing the 
> function to print out each file found with your call to glob(). The glob() 
> function returns an indexed array containing files found in the path you 
> specified, or an empty array if no files were found or false if glob() 
> failed. When I say "print" I'm referring to you using the echo language 
> construct, however, print is also another language construct.
>
> Therefore using echo in your function allows the foreach loop to continue 
> iterating through the array of files returned by glob(). Replacing that echo 
> with the return, the function ones one iteration in the foreach loop and 
> stops, returning that value. In your case, the function is returning index 0 
> of the array returned by glob().
>
> Make more sense?
>
> David McGlone  wrote:
>
>>On Wednesday, October 03, 2012 08:55:29 PM admin wrote:
>>> > Hi everyone, I have been playing around with some code the list
>>helped me
>>>
>>> with a while back and I'm not grasping the concept between return and
>>echo
>>> and the PHP manual doesn't answer this, unless I'm missing something.
>>There
>>> is an > example at the very bottom of PHP's return manual, but it's
>>> confusing.
>>>
>>> > So now I'm left wondering why return will only give me the first
>>result in
>>>
>>> an array, but echo will give me all the results of the array. Using
>>stuart's
>>> example he had sent me a while back I've messed around with it and
>>modified
>>> it > to better understand it:
>>> > function filename($prefix)
>>> >
>>> >{
>>> >
>>> >  $matches = glob('images/property_pics/'.$prefix.'*');
>>> >  foreach($matches as $filename){
>>> >  return $filename;
>>> >
>>> > }
>>> >
>>> >}
>>> >
>>> >echo completeImageFilename($row['MLS_No']);
>>> >
>>> >With the above code I only get the first image of each picture name,
>>but
>>>
>>> when I change return to echo, it groups and displays all the pics
>>that have
>>> the same picture name.
>>>
>>> >--
>>> >David M.
>>>
>>> The first loop and return is all you will get.
>>> Put the information into an array and return the array once the array
>>is
>>> built.
>>
>>I think I understand what your saying, but what I don't understand is
>>that
>>when I leave the current code intact and replace return $filename with
>>echo
>>$filename in the function, all the images display. Is this intended
>>behavior
>>between return and echo or is it just bad code on my part?
>>
>> --
>>David M.
>
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.

echo and return are not analogous items at all in PHP. They don't do
the same thing because their purpose is to do two entirely different
things.

For purposes of this discussion, the important bit about return is here:

"If called from within a function, the return statement immediately
ends execution of the current function, and returns its argument as
the value of the function call." [1]

The concept comes from making a call to a function and then returning
from it, where you will use the value that is returned.

echo, on the other hand, is about *displaying* values:

"echo — Output one or more strings" [2]

Let me try a bogus analogy:

A friend gives you a dollar to buy a soda from the machine. You take
the dollar, go over to the soda machine and get the soda.

In the case of return, you hand your friend the soda.

In the case of echo, you drink the soda.



Perhaps an example that is out of the context you are looking at might help:


Example 1:
==

function testreturn () {

  for ($i = 0 ; $i < 10 ; $i++ ) { // this will begin a loop where the
variable $i will start at value 0, and increase in value each time
through the loop by 1, stopping after $i is equal to 9.

return $1; // this will "short circuit" the loop and the enclosing
function, or the php script if called from the global context. In
other words, it *ends* the loop *and* function right there, sending
the value of $i (0 in this case) back to the calling function or
context.

  }
}


Example 2:
=

function testecho () {

  // Again, our for statement:
  for ($i = 0 ; $i < 10 ; $i++) {

echo $i; // this will emit the current value of $i to standard
output. when it is done, the loop continues

  }

}

Here, there is no return from the function, nothing is passed back to
the calling function or context.


Let's take a look at your code again:

function completeImageFilename($prefix)
{
  $matches = glob('images/property_pics/'.$prefix.'*');
  foreach($matches as $filename){
return $filename;
  }
}

echo completeImageFilename($row['MLS_No']);

When your loop contains nothing but the return $filename, it doesn't
matter how many entries are in your array, you are telling the
function to return with the first one in the array, no matter what.

If you modify it thusly:

function completeImageFilename($prefix)
{
  $matches = glob('images/property_pics/'.$prefix.'*'

Re: [PHP] Differences

2012-10-03 Thread tamouse mailing lists
On Wed, Oct 3, 2012 at 9:57 PM, David McGlone  wrote:
> Absolutely. I also think I learned that return can also work like echo if the
> code is written correctly.


No, no, no. Return does NOT do the same thing as echo, nor vice versa.
If you do try to make things work this way you are doing things
incorrectly. If you do try to make things work this way and it
actually works, you have gotten lucky, but are still doing it
incorrectly.

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



Re: [PHP] Differences

2012-10-03 Thread tamouse mailing lists
On Wed, Oct 3, 2012 at 10:03 PM, tamouse mailing lists
 wrote:
> On Wed, Oct 3, 2012 at 9:57 PM, David McGlone  wrote:
>> Absolutely. I also think I learned that return can also work like echo if the
>> code is written correctly.
>
>
> No, no, no. Return does NOT do the same thing as echo, nor vice versa.
> If you do try to make things work this way you are doing things
> incorrectly. If you do try to make things work this way and it
> actually works, you have gotten lucky, but are still doing it
> incorrectly.

Let's try another example, based on your code:

Example 1: using return
===

function completeImageFilename($prefix) //correcting function name
{
  $matches = glob('images/property_pics/'.$prefix.'*');
  foreach($matches as $filename){
  return $filename;
  }
}

echo "This is the complete image file name:
".completeImageFilename($row['MLS_No']) . PHP_EOL;

You will get one line of output with the text from the echo statement
and the first filename that matches.

Example 2: using echo
=

function completeImageFilename($prefix) //correcting function name
{
  $matches = glob('images/property_pics/'.$prefix.'*');
  foreach($matches as $filename){
echo "This is the file name from inside completeImageFilename: " .
$filename . PHP_EOL;
  }
}

echo "This is the complete image file name:
".completeImageFilename($row['MLS_No']) . PHP_EOL;

You will get several lines of output for each filename that matches
with the text from the echo statement inside the function, then one
more line that will contain *just* the text from the final echo
statement:

This is the file name from inside completeImageFilename:
images/property_pics/151136.jpg
This is the file name from inside completeImageFilename:
images/property_pics/151137.jpg
This is the file name from inside completeImageFilename:
images/property_pics/151138.jpg
This is the file name from inside completeImageFilename:
images/property_pics/151139.jpg
This is the complete image file name:

(the file names are bogus and just made up by me to illustrate)

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



Re: [PHP] Re: limiting

2012-10-09 Thread tamouse mailing lists
On Tue, Oct 9, 2012 at 5:19 PM, Matijn Woudt  wrote:
> On Wed, Oct 10, 2012 at 12:06 AM, Tim Streater  wrote:
>> On 09 Oct 2012 at 20:46, Matijn Woudt  wrote:
>>
>>> For example your previous post, you
>>> could have just looked up what the 'echo' and 'return' statements do
>>> in the PHP manual, and they are probably explained pretty OK in those
>>> books you own too. You probably could have answered the questions you
>>> posted here yourself, after reading PHP manual carefully.
>>
>> Here, the phrase "PHP manual" means:
>>
>>   http://www.php.net/manual/en/
>>
>> which I consider to be an excellent written resource for the language. In 
>> fact, I own no PHP books at all (whereas I do for 
>> JavaScript/HTML/CSS/SQLite) so that must say something about the quality of 
>> the on-line documentation. Further, it is written in a straightforward way, 
>> not trying to be clever (unlike some languages I could mention), so I can 
>> recommend it. It's available in languages other than English, too.
>>
>> --
>> Cheers  --  Tim
>>
>
> Thanks Tim! Should have mentioned the URL indeed.
> Don't forget that if you want to find the manual page for a function fast, try
> http://www.php.net/
> where  is the name you're looking for, so for example
> for return, you could use
> http://www.php.net/return
> And there ya go, PHP manual page for return!
>
> - Matijn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

The problems don't seem to be quite in understanding PHP, but
programming in general. O'Reilly this week has a special offer going
on books on general programming, which I hope no one minds if i spam
it in here:

 < 
http://shop.oreilly.com/category/deals/geek-code-owo.do?code=WKGKCD&imm_mid=0975a3&cmp=em-code-books-videos-geek-code-elist
>

The code is WKGKCD, which should automatically be applied.

Disclaimer: I am not an employee or stakeholder in O'Reilly, I just
like their books an awful lot, and they've helped me a great deal.

That said, I have to say I only own 1 PHP book: PHP Cookbook, which I
think is buried under quite a pile of stuff as I never have used it.
Yes, the online PHP docu is *that* *good*.

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



Re: [PHP] Re: limiting

2012-10-10 Thread tamouse mailing lists
On Wed, Oct 10, 2012 at 7:37 PM, Jim Giner  wrote:
> On 10/10/2012 4:27 PM, Matijn Woudt wrote:
>>
>> On Wed, Oct 10, 2012 at 10:26 PM, Ashley Sheridan
>>  wrote:
>>>
>>> On Wed, 2012-10-10 at 14:53 -0400, David McGlone wrote:
>>>
 On Wednesday, October 10, 2012 07:36:00 PM Tim Streater wrote:
>
> On 10 Oct 2012 at 19:17, David McGlone  wrote:
>
>
>>>
>>>
>>> BTW - in any of your other computer languages didn't they utilize a
>>> 'return' statement?  PHP's is no different.
>>
>>
>>
>>
>> back in  like '85, I learned Pascal that's the only language I learned
>> and
>> I

   don't recall if it used return.
>
>
>
> Mmmm. There's the problem. Pascal doesn't *have* a return statement. In
> Pascal, implicitly, you return when execution reaches the end of a
> function. In fact the same is true of PHP and JavaScript, but in those
> languages you can return early just by saying return.


> IMO, this is a major limitation of Pascal. I use returns wherever I
> feel
> like it - if I detect there's nothing more for the function to do, I
> return. Purists object to this; they say you should enter a function at
> one
> place and leave at one place. Well, that's a point of view. But more
> often
> that not it just leads to convoluted code in order to achieve that. The
> one
> time I *had* to use Pascal as that was the only option, I simply put a
> 999:
> label at the end of the function and did goto 999 wherever I wanted to
> do a
> return. Simples!


 goto was the thing that got on my nerves. Even to this day I hate that
 word
 with a passion.


>>>
>>>
>>> I think most people do, all but BASIC purists!
>>>
>>
>> Not really, goto can safe you a mess. In some situations it's much
>> easier and cleaner to use something like goto cleanup; at each error
>> case, instead of duplicating the cleanup code all over again (Closing
>> sockets, or in languages like C, freeing memory).
>>
>> - Matijn
>>
> haven't used a goto or go in 30 years.
>
>

It's the whence command that will get you every time (aka "comesfrom").

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



  1   2   3   4   >