Re: [PHP] How to "download" a multi-part file at the "server" side?

2013-11-02 Thread Aziz Saleh
On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg  wrote:

> Hi all.
>
> 1.
> I could have the proper "$_FILES["userfile"]["name"]" been echoed back, by
> replacing
>ContentBody cbFile = new
> FileBody(file, "image/png");
>
> with
>ContentBody cbFile = new
> FileBody(file);
>
>
>
> 2.
> However, now I am stuck with the following server-side code.
> No matter what I do, I always get a "no" echoed back (specifying that the
> file is not copied to its target place).
>
>
>
> ###
> 
> $headers = apache_request_headers();
>
> foreach ($headers as $header => $value)
> {
> if($header == "active_window_title")
> {
> $active_window_title = $value;
> break;
> }
> }
>
>
> $target_path = "/home/ajay/success.png";
>
> move_uploaded_file($_FILES["userfile"]["tmp_name"], $target_path);
> if(file_exists($target_path))
> {
> echo "yes";
> }
> else
> {
> echo "no";
> }
>
> echo "\n" . $_FILES["userfile"]["name"]; # I always get the proper
> file-name echoed.
>
> ?>
>
> 
>
>
>
>
>
> Any ideas what stupidity am I making in the PHP code?
>
>
> On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg  wrote:
>
> > Does not work :(
> >
> >
> > As per the code-snippet I pasted,
> >  $_FILES["userfile"]["name"]
> >
> > should be
> > /path/to/png/file.png
> >
> >
> > However, $_FILES["userfile"]["name"] is empty.
> >
> >
> > On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie  >wrote:
> >
> >> Fairly easy:
> >> http://www.php.net/manual/en/features.file-upload.post-method.php
> >>
> >>
> >> On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg 
> wrote:
> >>
> >>> Hi all.
> >>>
> >>> I intend to implement a use-case, wherein the client uploads a file in
> >>> multi-part format, and the server then stores the file in a mysql
> >>> database
> >>> (after "downloading it at the server side).
> >>>
> >>> I have been unable to find any immediate answers through googling; I
> will
> >>> be grateful if someone could start me in a direction to achieve the
> >>> "downloading at server via php" requirement.
> >>>
> >>> (Don't think it should matter, but I use Java to upload a file in
> >>> multi-part format).
> >>>
> >>> I will be grateful for some pointers.
> >>>
> >>> Thanks in advance
> >>>
> >>>
> >>> Thanks and Regards,
> >>> Ajay
> >>>
> >>
> >>
> >
> >
> > --
> > Regards,
> > Ajay
> >
>
>
>
> --
> Regards,
> Ajay
>

Ajay, try changing your mpEntity to:

new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE)

See if it makes a difference.


Re: [PHP] How to "download" a multi-part file at the "server" side?

2013-11-02 Thread Ajay Garg
Hi Aziz.
Thanks for the reply.

Unfortunately, making the change suggested by you does not make any
difference :(


Sorry, Thanks and Regards


On Sat, Nov 2, 2013 at 10:51 PM, Aziz Saleh  wrote:

>
>
>
> On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg  wrote:
>
>> Hi all.
>>
>> 1.
>> I could have the proper "$_FILES["userfile"]["name"]" been echoed back, by
>> replacing
>>ContentBody cbFile = new
>> FileBody(file, "image/png");
>>
>> with
>>ContentBody cbFile = new
>> FileBody(file);
>>
>>
>>
>> 2.
>> However, now I am stuck with the following server-side code.
>> No matter what I do, I always get a "no" echoed back (specifying that the
>> file is not copied to its target place).
>>
>>
>>
>>
>> ###
>> >
>> $headers = apache_request_headers();
>>
>> foreach ($headers as $header => $value)
>> {
>> if($header == "active_window_title")
>> {
>> $active_window_title = $value;
>> break;
>> }
>> }
>>
>>
>> $target_path = "/home/ajay/success.png";
>>
>> move_uploaded_file($_FILES["userfile"]["tmp_name"], $target_path);
>> if(file_exists($target_path))
>> {
>> echo "yes";
>> }
>> else
>> {
>> echo "no";
>> }
>>
>> echo "\n" . $_FILES["userfile"]["name"]; # I always get the proper
>> file-name echoed.
>>
>> ?>
>>
>> 
>>
>>
>>
>>
>>
>> Any ideas what stupidity am I making in the PHP code?
>>
>>
>> On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg  wrote:
>>
>> > Does not work :(
>> >
>> >
>> > As per the code-snippet I pasted,
>> >  $_FILES["userfile"]["name"]
>> >
>> > should be
>> >
>> /path/to/png/file.png
>> >
>> >
>> > However, $_FILES["userfile"]["name"] is empty.
>> >
>> >
>> > On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie > >wrote:
>> >
>> >> Fairly easy:
>> >> http://www.php.net/manual/en/features.file-upload.post-method.php
>> >>
>> >>
>> >> On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg 
>> wrote:
>> >>
>> >>> Hi all.
>> >>>
>> >>> I intend to implement a use-case, wherein the client uploads a file in
>> >>> multi-part format, and the server then stores the file in a mysql
>> >>> database
>> >>> (after "downloading it at the server side).
>> >>>
>> >>> I have been unable to find any immediate answers through googling; I
>> will
>> >>> be grateful if someone could start me in a direction to achieve the
>> >>> "downloading at server via php" requirement.
>> >>>
>> >>> (Don't think it should matter, but I use Java to upload a file in
>> >>> multi-part format).
>> >>>
>> >>> I will be grateful for some pointers.
>> >>>
>> >>> Thanks in advance
>> >>>
>> >>>
>> >>> Thanks and Regards,
>> >>> Ajay
>> >>>
>> >>
>> >>
>> >
>> >
>> > --
>> > Regards,
>> > Ajay
>> >
>>
>>
>>
>> --
>> Regards,
>> Ajay
>>
>
> Ajay, try changing your mpEntity to:
>
> new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE)
>
> See if it makes a difference.
>


Ajay


[PHP] Re: How to "download" a multi-part file at the "server" side?

2013-11-02 Thread Ajay Garg
I just came across http://www.w3schools.com/php/php_file_upload.asp, and
tested it..
It works fine, when the file is uploaded via a form.


It does seem that the client-method might indeed play a role.
Here is my Java code for uploading the file ::


###
HttpClient httpclient = new DefaultHttpClient();

httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_1);

HttpPost httppost = new HttpPost(URL);
File file = new File("/path/to/png/file.png");

// Send the image-file data as a Multipart-data.
MultipartEntity mpEntity = new MultipartEntity();
ContentBody cbFile = new FileBody(file, "image/png");
mpEntity.addPart("userfile", cbFile);

httppost.setEntity(mpEntity);

HttpResponse response = httpclient.execute(httppost);
###


Any ideas if making a change at the client (Java) OR/AND server (PHP) might
do the trick?


On Sat, Nov 2, 2013 at 6:06 PM, Ajay Garg  wrote:

> Hi all.
>
> I intend to implement a use-case, wherein the client uploads a file in
> multi-part format, and the server then stores the file in a mysql database
> (after "downloading it at the server side).
>
> I have been unable to find any immediate answers through googling; I will
> be grateful if someone could start me in a direction to achieve the
> "downloading at server via php" requirement.
>
> (Don't think it should matter, but I use Java to upload a file in
> multi-part format).
>
> I will be grateful for some pointers.
>
> Thanks in advance
>
>
> Thanks and Regards,
> Ajay
>



-- 
Regards,
Ajay


Re: [PHP] preg_replace

2013-11-01 Thread Adam Szewczyk
Hi,

On Fri, Nov 01, 2013 at 11:06:29AM -0400, leam hall wrote:
> Despite my best efforts to ignore preg_replace...
Why? :)

> PHP Warning:  preg_replace(): Delimiter must not be alphanumeric or
> backslash
> 
> Thoughts?
You are just using it wrong.
http://us2.php.net/manual/en/regexp.reference.delimiters.php

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



Re: [PHP] FYI: Apache/PHP exploit

2013-10-31 Thread Camilo Sperberg


On 31 okt. 2013, at 01:55, Joshua Kehn  wrote:

> Summary for those on phones?
> 
> Best,
> 
> -Josh
> ___
> http://byjakt.com
> Currently mobile
> 
>> On Oct 30, 2013, at 8:37 PM, Tamara Temple  wrote:
>> 
>> This info cruised by my screen from G+ today, thought I’d at least pass it 
>> along:
>> 
>> http://www.exploit-db.com/exploits/29290/
>> 
>> 
>> 
>> -- 
>> 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
> 

It opens a shell on default ubuntu/debian lamp's, compromising several versions 
of php, including the 5.5 branch. 

Sent from my iPhone 6 Beta [Confidential use only]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Persistent connections

2013-10-26 Thread Nibin V M
Hello,

I have been reading docs and many are telling that persistent connections
are kept open indefinitely. But I found in PHP docs that it will not close
after script execution like requesting  a page; so should it close after
the request is over?

So when exactly a persistent connection should close?

Please advice.

-- 
Regards

Nibin.


Re: [PHP] I am puzzled. Error on one site, no error on the other

2013-10-26 Thread Aziz Saleh
On Fri, Oct 25, 2013 at 8:27 PM, Stephen  wrote:

> Problem Situation
>
> I have two web sites on the same shared host. They share code for the
> control panel. When executed for one site I get a warning (reproducible
> always), but on the other there is no warning.
>
> One my home server, set up in the same way, I do not get a warning for
> either site.
>
> The warning is from this code:
>
> if ( in_array( $keys, $photo_ids ) )
>
> *Warning*: in_array() expects parameter 2 to be array, null given in
> */home/rois3324/include/**cpprocessforms.php* on line *203*
>
> Steps
>
> 1) Photos are transferred to incoming directory using ftp.
> 2) Photo data is imported into database and files moved to web site's file
> system
> 3) Photos are linked to a "category" by
> i) Specifying photos to consider by entering filespec using wildcards
> ii) User presented with photos
> iii) User selects photos to be added to category and clicks process
> button
> iv) Form returns array of photo_ids (key in database table)
> v) Form processor creates entry in "link" table that links category_id
> to photo_id
> vi) A check is made to detect and reject when the link already exists
>
> This is where the error occurs
>
> I have looked at the code, but I am at a total loss to figure out why I
> have trouble on one site and not the other, even though they are using the
> code. And my home development system has no problems.
>
> I can't play trial and error on the development system.
>
> Anyone have any ideas?
>
> This is the code where the warning is triggered:
>
> function linkphotos( $dbh, $x ) {
>
>   global $thumbsdirectory;
>
>   $ret_str = "";
>   $cat_id = $x['category'];
>   $photos = $x['list'];
>   $sql0 = "SELECT photo_filename FROM photographs WHERE photo_id = :id";
>   $sql1 = "SELECT photo_id FROM gallery_photos WHERE photo_category = :id";
>   $sql2= "INSERT INTO gallery_photos VALUES ( :id, :photo_id, :order )";
>
>   $stmt = $dbh->prepare($sql0);
>   try {
>   foreach( $photos as $keys=> $on) {
>   $stmt->bindValue(':id', $keys);
>   $stmt->execute();
>   $row = $stmt->fetch(PDO::FETCH_ASSOC)**;
>   $filenames[$keys] = $thumbsdirectory . "/" . $row['photo_filename'];
>  }
>   } catch (PDOException $e) {
> return 'Error selecting existing file names: ' . $e->getMessage();
>   }
>
>   $stmt = $dbh->prepare($sql1);
>   try {
>   $stmt->bindValue(':id', $cat_id);
>   $stmt->execute();
>   while ( list( $id ) = $stmt->fetch(PDO::FETCH_NUM)) {
> $photo_ids[] = $id;
>   }
> } catch (PDOException $e) {
> return 'Error selecting existing photos: ' . $e->getMessage();
>   }
>
>   $stmt = $dbh->prepare($sql2);
>   try {
>   $stmt->bindValue(':id', $cat_id);
>   foreach( $photos as $keys=> $on) {
> $ret_str .=  htmlimage($filenames[$keys], $filenames[$keys] ) .
> "";
> if ( in_array( $keys, $photo_ids ) ) { <<< $ret_str .= "  Duplicate. Already in Category.";
> } else {
>   $stmt->bindValue(':photo_id', $keys);
>   $stmt->bindValue(':order', $keys);
>   $stmt->execute();
>   $ret_str .= "  Added to Category.";
> }
>   }
>   } catch (PDOException $e) {
> return 'Error inserting new photos: ' . $e->getMessage();
>   }
>
>   return $ret_str;
> }
>
> --
> Stephen
>
>
Your $photo_ids array is not declared. After
$photos = $x['list'];
add
$photo_ids = array();


Re: [PHP] framework or not

2013-10-26 Thread Stuart Dallas
On 25 Oct 2013, at 15:40, Robert Cummings  wrote:

> On 13-10-25 10:17 AM, Stuart Dallas wrote:
>> On 25 Oct 2013, at 15:01, Robert Cummings  wrote:
>> 
>>> On 13-10-24 09:41 PM, Larry Garfield wrote:
>>>> On 10/23/2013 08:51 AM, Jay Blanchard wrote:
>>>>> [snip] a bitter rant[/snip]
>>>>> 
>>>>> Dang Larry - bad night?
>>>> 
>>>> That wasn't a bitter rant.  You haven't seen me bitter. :-)  That was
>>>> "tough love" to the OP.  I don't see a reason to pussyfoot around the
>>>> original question, which is one that comes up about once a month.  The
>>>> answer is always the same: How much is your time worth?
>>> 
>>> Basic math...
>>> 
>>>Life: finite
>>>Time: infinite
>>> 
>>>finite / infinite = 0
>>> 
>>> *sniffle*
>> 
>> Who's valuation of your time actually matters? Yours, and yours alone.
>> 
>> Therefore:
>> 
>> Life: n years
>> Time I can benefit from my life: n years
>> 
>> n years / n years = 1
>> 
>> *hoorah*
>> 
>> Your time is the most precious commodity you have.
>> 
>> Whether you use a framework or not you will (hopefully) reuse code between 
>> projects. If you choose to make part of that reused code one of the many 
>> frameworks that exist, you need only do one thing to ensure it continues to 
>> be worth using: how much of your time do you spend battling against the 
>> restrictions of the framework? If that's sufficiently low then using that 
>> framework is probably a good thing. If a significant portion of your time is 
>> spent battling the framework it's time to make a change.
>> 
>> Also remember that the only person who can truthfully judge whether you're 
>> "wasting time" is you, unless you earn money by selling your time to someone 
>> else in which case they have some right to decide what constitutes a waste 
>> of the time for which they're paying. I found the experience of writing my 
>> own framework to be hugely beneficial to my future productivity, but I might 
>> have struggled to justify spending the extra time it took to my employer at 
>> the time.
> 
> You stripped away the context of my response. By removing the evil grin you 
> made it look like I was serious. You should be a reporter ;)

Who says I'm not! :)

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] Persistent connections

2013-10-26 Thread Stuart Dallas
On 25 Oct 2013, at 12:51, Nibin V M  wrote:

> Thank you for the quick response Stuart...one more doubt..at 
> http://php.net/manual/en/features.persistent-connections.php they states
> 
> =
> This means that when the same client makes a second request to the server, it 
> may be served by a different child process than the first time. When opening 
> a persistent connection, every following page requesting SQL services can 
> reuse the same established connection to the SQL server
> =
> 
> Is the persistent connection pool is re-used between apache child processes ? 

No, connections are not shared between PHP processes. Nothing is shared between 
PHP processes.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


> On Fri, Oct 25, 2013 at 3:54 PM, Stuart Dallas  wrote:
> On 25 Oct 2013, at 11:10, Nibin V M  wrote:
> 
> > I have been reading docs and many are telling that persistent connections
> > are kept open indefinitely. But I found in PHP docs that it will not close
> > after script execution like requesting  a page; so should it close after
> > the request is over?
> >
> > So when exactly a persistent connection should close?
> >
> > Please advice.
> 
> A persistent connection is closed when the PHP process ends, or it gets 
> disconnected by the server-side or due to a network error. Attempting to 
> explicitly close a persistent connection will do nothing without complaining.
> 
> -Stuart
> 
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
> 
> 
> 
> -- 
> Regards
> 
> Nibin.
> 
> http://TechsWare.in


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



Re: [PHP] framework or not

2013-10-26 Thread Robert Cummings

On 13-10-24 09:41 PM, Larry Garfield wrote:

On 10/23/2013 08:51 AM, Jay Blanchard wrote:

[snip] a bitter rant[/snip]

Dang Larry - bad night?


That wasn't a bitter rant.  You haven't seen me bitter. :-)  That was
"tough love" to the OP.  I don't see a reason to pussyfoot around the
original question, which is one that comes up about once a month.  The
answer is always the same: How much is your time worth?


Basic math...

Life: finite
Time: infinite

finite / infinite = 0

*sniffle*

Oh wait... you meant in the smaller scheme of things >:)

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



Re: [PHP] framework or not

2013-10-25 Thread Stuart Dallas
On 25 Oct 2013, at 15:01, Robert Cummings  wrote:

> On 13-10-24 09:41 PM, Larry Garfield wrote:
>> On 10/23/2013 08:51 AM, Jay Blanchard wrote:
>>> [snip] a bitter rant[/snip]
>>> 
>>> Dang Larry - bad night?
>> 
>> That wasn't a bitter rant.  You haven't seen me bitter. :-)  That was
>> "tough love" to the OP.  I don't see a reason to pussyfoot around the
>> original question, which is one that comes up about once a month.  The
>> answer is always the same: How much is your time worth?
> 
> Basic math...
> 
>Life: finite
>Time: infinite
> 
>finite / infinite = 0
> 
> *sniffle*

Who's valuation of your time actually matters? Yours, and yours alone.

Therefore:

Life: n years
Time I can benefit from my life: n years

n years / n years = 1

*hoorah*

Your time is the most precious commodity you have.

Whether you use a framework or not you will (hopefully) reuse code between 
projects. If you choose to make part of that reused code one of the many 
frameworks that exist, you need only do one thing to ensure it continues to be 
worth using: how much of your time do you spend battling against the 
restrictions of the framework? If that's sufficiently low then using that 
framework is probably a good thing. If a significant portion of your time is 
spent battling the framework it's time to make a change.

Also remember that the only person who can truthfully judge whether you're 
"wasting time" is you, unless you earn money by selling your time to someone 
else in which case they have some right to decide what constitutes a waste of 
the time for which they're paying. I found the experience of writing my own 
framework to be hugely beneficial to my future productivity, but I might have 
struggled to justify spending the extra time it took to my employer at the time.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] Persistent connections

2013-10-25 Thread Stuart Dallas
On 25 Oct 2013, at 11:10, Nibin V M  wrote:

> I have been reading docs and many are telling that persistent connections
> are kept open indefinitely. But I found in PHP docs that it will not close
> after script execution like requesting  a page; so should it close after
> the request is over?
> 
> So when exactly a persistent connection should close?
> 
> Please advice.

A persistent connection is closed when the PHP process ends, or it gets 
disconnected by the server-side or due to a network error. Attempting to 
explicitly close a persistent connection will do nothing without complaining.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] framework or not

2013-10-24 Thread Marc Guay
> I'm looking forward to the day that I'll know everything and can stop all 
> this learning nonsense.


Sounds like the attitude most people take when they sit down to a
keyboard.  (Ref: http://xkcd.com/386/)

Off-topic is the new on-topic
Marc

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



Re: [PHP] framework or not

2013-10-23 Thread Larry Martell
On Wed, Oct 23, 2013 at 11:08 AM, Tedd Sperling wrote:

> On Oct 23, 2013, at 12:34 PM, Larry Martell 
> wrote:
> > Was it Brian Kernighan who said the 3 rules of programming are:
> >
> > 1. Keep it simple.
> > 2. Build it in stages.
> > 3. Let someone else do the hard part.
>
> Sounds good to me.
>
> I would also add:
>
> I've learned something new everyday of my life -- and I'm getting damned
> tired of it.
>
> I'm looking forward to the day that I'll know everything and can stop all
> this learning nonsense.
>
>
"Everything that can be invented has been invented."
-Charles H. Duell, Commissioner of US patent office, 1899.


Re: [PHP] framework or not

2013-10-23 Thread Larry Martell
On Wed, Oct 23, 2013 at 10:26 AM, Tedd Sperling wrote:

> On Oct 23, 2013, at 12:04 AM, Robert Cummings 
> wrote:
>
> > On 13-10-22 05:38 PM, Larry Garfield wrote:
> >> If you need more convincing, I will cite Fred Brooks:
> >>
> >> http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html
> >
> > Excellent article, thanks for the pointer. So many assertions have stood
> the test of time thus far.
> >
> > Cheers,
> > Rob.
>
> Yes, it was an excellent article.
>
> One of the things I liked about the article was the concept of
> "Incremental Development", which is something I have practiced since the
> Old Apple ][ days (Incidentally, he states he learned of this in 1958 -- is
> that a typo?).
>
> In 1977, I started many of my programs with (pardon my failing memory of
> AppleSoft syntax):
>
> Gosub GatherData()
> Gosub ProcessData()
> Gosub PresentDate()
> END
>
> It ran, but didn't do anything. Incidentally, that resembles a one-pass
> MVC design, does it not?
>
> In any event, I would flesh out the code until I got what I wanted.
>
> Maybe that's one of the reasons why Android or iOS Development starts with
> a Default "Hello World" App that does very little than run.
>
> Start simple, develop complex.
>

Is there any other way to do it? I've been programming since 1975 and
that's what I was taught and that's how always do it.

Was it Brian Kernighan who said the 3 rules of programming are:

1. Keep it simple.
2. Build it in stages.
3. Let someone else do the hard part.


Re: [PHP] framework or not

2013-10-22 Thread Robert Cummings

On 13-10-22 05:38 PM, Larry Garfield wrote:

If you need more convincing, I will cite Fred Brooks:

http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html


Excellent article, thanks for the pointer. So many assertions have stood 
the test of time thus far.


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



Re: [PHP] If date is greater than

2013-10-20 Thread Tedd Sperling

On Oct 20, 2013, at 4:01 AM, Ashley Sheridan  wrote:

> Yes, I was going to ask, why are you storing your dates as strings?
> MySQL has a perfectly good DATE type. It's also generally faster
> comparing dates within a MySQL query than PHP code.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Agreed.

Plus, there are many date functions provided by MySQL that are easier 
(possibility faster) than what you can do in PHP.

Check these out:

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date

tedd

___
tedd sperling
tedd.sperl...@gmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Algorithm Help

2013-10-20 Thread German Geek
t; > Twitter: @geekdenz
>> > Blog: http://www.thheuer.com
>> >
>> >
>> > On 20 October 2013 15:33, German Geek  wrote:
>> >
>> >> This is how I would approach/imagine it:
>> >>
>> >>
>> >>
>> https://docs.google.com/drawings/d/111RISgcHyAg8NXem4H1NXnxByRUydL8GiYlGkobJwus/edit
>> >>
>> >> Tom has been with Andrew 0 times.
>> >> Tom has been with Shelly 1 time.
>> >> Christine has been with Andrew 2 times.
>> >> ...
>> >>
>> >> So the Graph maintains who has been with who how often.
>> >>
>> >> For 10 or even 20 kids you might be able to go through all links (brute
>> >> force).
>> >>
>> >> The number of links (including the ones with 0 weight) is
>> >> #links = n*(n-1)/2
>> >> which is the number of links you have to maintain and then check when
>> you
>> >> want to know who should go with whom.
>> >>
>> >> So, if
>> >> n=10: #links = 10*9/2 = 45
>> >> n=20: #links = 20*19/2 = 190
>> >> n=30: #links = 30*29/2 = 435
>> >>
>> >> I think even for reasonably large groups a computer can do the job
>> >> easily. I would find it quite hard to do it on paper though, so I
>> think you
>> >> should program it.
>> >>
>> >> You could simply store the graph in an array, and then optionally
>> persist
>> >> it to a db or file:
>> >>
>> >> You would get e.g.:
>> >>
>> >> $graph = array(
>> >>   '0,1' => 0,
>> >>   '0,2' => 2,
>> >> ...
>> >>
>> >> Edit: Actually, maybe you can do it in a two-dimensional array, where
>> no
>> >> node is connected to itself:
>> >>
>> >> $n=4;
>> >> function init() {
>> >>   global $n;
>> >>   $graph = array();
>> >>   for ($i = 0; $i < $n; ++$i) {
>> >> $graph[$i] = array();
>> >> for ($j = 0; $j < $n; ++$j) {
>> >>   $graph[$i][$j] = 0;
>> >> }
>> >>   }
>> >>   return $graph;
>> >> }
>> >>
>> >> $graph = init();
>> >>
>> >> Sorry, I might be running a bit out of time here...
>> >>
>> >> You can use an implementation of a graph, for example this one:
>> >>
>> >>
>> http://pear.php.net/package/Structures_Graph/docs/latest/li_Structures_Graph.html
>> >>
>> >> But it might be overkill as the 2-dimensional array would even do the
>> >> trick and there might be less overhead although you are requiring more
>> >> space than needed (n*(n-1)/2+n cells more to be exact).
>> >>
>> >> You could store it in a hashmap/associative array like this:
>> >> > >>  $graph = array(
>> >>'A' => array('B' => 1, 'F' => 2),
>> >>'B' => array('A' => 3, 'D' => 4, 'E' => 5),
>> >>'C' => array('F' => 6),
>> >>'D' => array('B' => 7, 'E' => 8),
>> >>'E' => array('B' => 9, 'D' => 10, 'F' => 11),
>> >>'F' => array('A' => 12, 'E' => 13, 'C' => 14),
>> >>  );
>> >>  (Sorry if large font). Source of idea:
>> >> http://www.sitepoint.com/data-structures-4/
>> >>
>> >> Cheers,
>> >> T
>> >>
>> >> Tim-Hinnerk Heuer
>> >>
>> >> Twitter: @geekdenz
>> >> Blog: http://www.thheuer.com
>> >>
>> >>
>> >> On 4 October 2013 02:17, Nickolas Whiting  wrote:
>> >>
>> >>> Round Robin algorithm should solve this and is a fairly quick
>> alogrithm
>> >>> ...
>> >>> http://en.wikipedia.org/wiki/Round-robin
>> >>>
>> >>> An example can be found
>> >>> http://forrst.com/posts/PHP_Round_Robin_Algorithm-2zm
>> >>>
>> >>>
>> >>> On Tue, Oct 1, 2013 at 2:51 PM, Floyd Resler 
>> >>> wrote:
>> >>>
>> >>> > Here's my task: A group of kids is going to be staying with
>> different
>> >>> host
>> >>> > families throughout the next 8 months.  The number of kids staying
>> >>> with a
>> >>> > host family can range from 2 to 10.  When deciding which kids should
>> >>> stay
>> >>> > together at a host family, the idea is for the system to put
>> together
>> >>> kids
>> >>> > who have stayed with each other the least on past weekends.  So, if
>> a
>> >>> host
>> >>> > family can keep 5 kids, then the group of 5 kids who have stayed
>> >>> together
>> >>> > the least will be chosen.
>> >>> >
>> >>> > I can't think of an easy, quick way to accomplish this.  I've tried
>> >>> > various approaches that have resulted in a lot of coding and being
>> very
>> >>> > slow.  My idea was to give each group of kids a score and the lowest
>> >>> score
>> >>> > is the group that is selected.  However, this approach wound of
>> >>> iterating
>> >>> > through several arrays several times which was really slow.  Does
>> >>> anyone
>> >>> > have any ideas on this puzzle?
>> >>> >
>> >>> > Thanks!
>> >>> > Floyd
>> >>> >
>> >>> >
>> >>> > --
>> >>> > PHP General Mailing List (http://www.php.net/)
>> >>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>> --
>> >>> Nickolas Whiting
>> >>> Freelance Consultant
>> >>>
>> >>
>> >>
>> >
>>
>
>


Re: [PHP] Algorithm Help

2013-10-20 Thread Ayush Ladia
=10: #links = 10*9/2 = 45
> >> n=20: #links = 20*19/2 = 190
> >> n=30: #links = 30*29/2 = 435
> >>
> >> I think even for reasonably large groups a computer can do the job
> >> easily. I would find it quite hard to do it on paper though, so I think
> you
> >> should program it.
> >>
> >> You could simply store the graph in an array, and then optionally
> persist
> >> it to a db or file:
> >>
> >> You would get e.g.:
> >>
> >> $graph = array(
> >>   '0,1' => 0,
> >>   '0,2' => 2,
> >> ...
> >>
> >> Edit: Actually, maybe you can do it in a two-dimensional array, where no
> >> node is connected to itself:
> >>
> >> $n=4;
> >> function init() {
> >>   global $n;
> >>   $graph = array();
> >>   for ($i = 0; $i < $n; ++$i) {
> >> $graph[$i] = array();
> >> for ($j = 0; $j < $n; ++$j) {
> >>   $graph[$i][$j] = 0;
> >> }
> >>   }
> >>   return $graph;
> >> }
> >>
> >> $graph = init();
> >>
> >> Sorry, I might be running a bit out of time here...
> >>
> >> You can use an implementation of a graph, for example this one:
> >>
> >>
> http://pear.php.net/package/Structures_Graph/docs/latest/li_Structures_Graph.html
> >>
> >> But it might be overkill as the 2-dimensional array would even do the
> >> trick and there might be less overhead although you are requiring more
> >> space than needed (n*(n-1)/2+n cells more to be exact).
> >>
> >> You could store it in a hashmap/associative array like this:
> >>  >>  $graph = array(
> >>'A' => array('B' => 1, 'F' => 2),
> >>'B' => array('A' => 3, 'D' => 4, 'E' => 5),
> >>'C' => array('F' => 6),
> >>'D' => array('B' => 7, 'E' => 8),
> >>'E' => array('B' => 9, 'D' => 10, 'F' => 11),
> >>'F' => array('A' => 12, 'E' => 13, 'C' => 14),
> >>  );
> >>  (Sorry if large font). Source of idea:
> >> http://www.sitepoint.com/data-structures-4/
> >>
> >> Cheers,
> >> T
> >>
> >> Tim-Hinnerk Heuer
> >>
> >> Twitter: @geekdenz
> >> Blog: http://www.thheuer.com
> >>
> >>
> >> On 4 October 2013 02:17, Nickolas Whiting  wrote:
> >>
> >>> Round Robin algorithm should solve this and is a fairly quick alogrithm
> >>> ...
> >>> http://en.wikipedia.org/wiki/Round-robin
> >>>
> >>> An example can be found
> >>> http://forrst.com/posts/PHP_Round_Robin_Algorithm-2zm
> >>>
> >>>
> >>> On Tue, Oct 1, 2013 at 2:51 PM, Floyd Resler 
> >>> wrote:
> >>>
> >>> > Here's my task: A group of kids is going to be staying with different
> >>> host
> >>> > families throughout the next 8 months.  The number of kids staying
> >>> with a
> >>> > host family can range from 2 to 10.  When deciding which kids should
> >>> stay
> >>> > together at a host family, the idea is for the system to put together
> >>> kids
> >>> > who have stayed with each other the least on past weekends.  So, if a
> >>> host
> >>> > family can keep 5 kids, then the group of 5 kids who have stayed
> >>> together
> >>> > the least will be chosen.
> >>> >
> >>> > I can't think of an easy, quick way to accomplish this.  I've tried
> >>> > various approaches that have resulted in a lot of coding and being
> very
> >>> > slow.  My idea was to give each group of kids a score and the lowest
> >>> score
> >>> > is the group that is selected.  However, this approach wound of
> >>> iterating
> >>> > through several arrays several times which was really slow.  Does
> >>> anyone
> >>> > have any ideas on this puzzle?
> >>> >
> >>> > Thanks!
> >>> > Floyd
> >>> >
> >>> >
> >>> > --
> >>> > PHP General Mailing List (http://www.php.net/)
> >>> > To unsubscribe, visit: http://www.php.net/unsub.php
> >>> >
> >>> >
> >>>
> >>>
> >>> --
> >>> Nickolas Whiting
> >>> Freelance Consultant
> >>>
> >>
> >>
> >
>


Re: [PHP] If date is greater than

2013-10-20 Thread Ashley Sheridan
On Sun, 2013-10-20 at 00:00 -0400, Bastien wrote:

> 
> Thanks,
> 
> Bastien
> 
> > On Oct 19, 2013, at 10:44 PM, John Taylor-Johnston 
> >  wrote:
> > 
> > I have date strings in my mysql db. -mm-dd.
> > I want to parse to see if the date is greater than november 2011 and less 
> > than december 2012.
> > 
> > Is this the right approach? How bad is my syntax?
> > 
> > |function dates_range($todaynow)
> > { |
> > |$date1=strtotime("2011-11-01");
> > $date2=strtotime("2012-12-31");
> >   if (|||($|todaynow |>= $date1) and |($|||todaynow| <= 
> > $date2)||)
> > ||   {
> > ||   # do something
> >    }
> > }
> > |||
> 
> Easiest to convert to integers and then compare


Yes, I was going to ask, why are you storing your dates as strings?
MySQL has a perfectly good DATE type. It's also generally faster
comparing dates within a MySQL query than PHP code.

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




Re: [PHP] Trying to understand what is happening in this code

2013-10-11 Thread Stuart Dallas
On 11 Oct 2013, at 16:20, Nathan Grey  wrote:

> Stuart, Jose - Thanks for your quick response. Are you saying that the 
> processor echos all the html tags it sees. Is it doing something like this to 
> the script:
> 
> echo 
> echo The first twenty Fibonacci numbers:
> echo 
>  $first = 0;
>$second = 1;
>for ($i = 0; $i < 20; $i++) {
> ?>
> echo  
>$temp = $first + $second;
> $first = $second;
> $second = $temp;
> 
>   } ?>
> echo  
> echo  
> 
> Or is it just the line in question that is being echoed?

I'm not sure exactly what it gets compiled to, but I also don't see why it 
matters. All that matters is that content outside of PHP tags will simply get 
echo'd.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] php.ini

2013-10-09 Thread Jim Giner

On 10/9/2013 3:14 AM, Simon Schick wrote:

On Tue, Oct 8, 2013 at 9:50 PM, Jim Giner wrote:


On 10/8/2013 2:42 PM, Simon Schick wrote:


On Tue, Oct 8, 2013 at 5:25 PM, Jim Giner *
*wrote:

  re: changing ini settings.


If my running script modifies an ini setting I currently believe that
that
changed setting will apply to that specific process and any others that
run
after that from that same folder (since i have an ini file in each folder
currently).  Correct?

And if I do make a setting change as above, it only affects the ini file
and processes in that folder, thus leaving the setting unchanged in any
and
all other folders above that one.  Correct?

And from the article pointed out to me, I get the impression that the
search for ini files bubbles up from the executing folder.  If that is
so,
then am I correct in assuming that settings in the lowest ini file take
precedence over any found in 'bubbled-up' ini files?


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


  Hi, Jim


Never mind my last paragraph ... I was thinking the wrong way of what you
wrote earlier.

I haven't tested it properly in every detail, but from the perspective of
what I know it's like you wrote.

The file that's mentioned as "php.ini" is the main configuration file of
your php-installation. It may be, that the user-ini file was renamed to
"php.ini" as well, but if you read about "php.ini", they always mean the
configuration-file that you see listed in the output of phpinfo() as
"Configuration File (php.ini) Path".

* You can rename the user-ini file by changing the user_ini.filename
setting in the php.ini file (as written on the page I linked you to)

* The php-settings are restored after/before each script-execution

* The manual doesn't catch if a user-ini file was found ... just that it
bubbles up to the document_root. Maybe the configuration found in user-ini
files is merged, or just the first file is taken.

* I don't know what happens to configuration you apply f.e. in nginx ... I
know neither when settings in php-fpm are applied ... that's something
left
for testing, or until somebody finds the documentation explaining it (I
know there is one ...), but I guess they're applied after the php.ini and
before the user-ini files.
Examples are listed here:
http://php.net/manual/en/**install.fpm.configuration.php#**example-60<http://php.net/manual/en/install.fpm.configuration.php#example-60>

* What you set using set_ini() is just applied for the rest of the
currently running script.

Bye
Simon

  I understand most of what you wrote and agree all except for one thing.

  You keep using the name "user.ini" and I asked for clarification on this
earlier.  Do I have to create files named EXACTLY that way, or are
"php.ini" files correctly named?


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



Hi, Jim

You can define the name for this file your configuration (php basic
configuration file or in the webserver, calling the cgi/fcgi script).

The configuration is called "user_ini.filename", and it's default value is
set to ".user.ini". Of course, your provider (or you, if you're the
administrator of the php-instance) may changed this setting to something
like "php.ini". Then the php-process will search for a "php.ini" file in
the directories a user-ini file is searched in.
When talking about configuration files, this may be misleading, as the
basic configuration file is refered as "php.ini" over all in the
documentation.

I don't believe, that the PHP process would search for a file called
"php.ini", if the value is set to something like ".user.ini" - if that's
what you mean.

It may be, that you can change the setting later on, but it will have no
effect (f.e. if you change it using set_ini() ... if it doesn't trigger a
E_WARNING or something the like).

Hope this answers the remaining question. If not, I kindly ask you to write
some examples.

Bye,
Simon

Ok - here is what I see happening now.  PHPINFO shows a setting named 
'user_ini.filename' set to '.user.ini'  At the same time the setting 
"loaded configuration file" shows that a "php.ini" file was loaded from 
the current sub folder that this call to phpinfo was running in (as I 
expect!).  So apparently my host has set php to look for "user.ini" 
files, but "php.ini" files are still accepted and loaded.


I'm guessing that despite the user_ini filename setting, a PHP.ini file 
will still be read, which suits me just fine.


Thanks for all the help Simon!

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



Re: [PHP] php.ini

2013-10-09 Thread Simon Schick
Hi, Jim

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

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

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

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

Bye,
Simon


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

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


Re: [PHP] php.ini

2013-10-09 Thread Jim Giner

re: changing ini settings.

If my running script modifies an ini setting I currently believe that 
that changed setting will apply to that specific process and any others 
that run after that from that same folder (since i have an ini file in 
each folder currently).  Correct?


And if I do make a setting change as above, it only affects the ini file 
and processes in that folder, thus leaving the setting unchanged in any 
and all other folders above that one.  Correct?


And from the article pointed out to me, I get the impression that the 
search for ini files bubbles up from the executing folder.  If that is 
so, then am I correct in assuming that settings in the lowest ini file 
take precedence over any found in 'bubbled-up' ini files?


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



Re: [PHP] php.ini

2013-10-09 Thread Jim Giner

On 10/8/2013 11:13 AM, Simon Schick wrote:

Hi, Jim

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

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

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

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

Bye,
Simon


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


Can someone give me an understanding of how the .ini settings are located
and combined?  I am under the impression that there is a full settings .ini
file somewhere up high in my host's server tree and that any settings I
create in .ini files in each of my domain folders are appended/updated
against the 'main' ini settings to give me a 'current' group of php.ini
settings.

What I'm looking to find out is does an ini setting established in a test
subdomain of my site affect those ini settings outside of my test subdomain?

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





I need more!
1 - the doc you mentioned refers to 'user.ini'.  Does that literally 
mean the file is called 'USER.ini'?  I have been placing my .ini 
overrides/settings in each of my folders under the name 'php.ini'.  Do I 
have to change them all because it seems that they are working fine.


2 - I didn't understand your last paragraph.

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



[PHP] php.ini

2013-10-08 Thread Jim Giner
Can someone give me an understanding of how the .ini settings are 
located and combined?  I am under the impression that there is a full 
settings .ini file somewhere up high in my host's server tree and that 
any settings I create in .ini files in each of my domain folders are 
appended/updated against the 'main' ini settings to give me a 'current' 
group of php.ini settings.


What I'm looking to find out is does an ini setting established in a 
test subdomain of my site affect those ini settings outside of my test 
subdomain?


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



Re: [PHP] date time problem

2013-10-07 Thread Jim Giner

On 10/6/2013 11:21 PM, Romain CIACCAFAVA wrote:

An easier way to do that would be using the diff() method of a DateTime object 
on another.

Regards
Romain Ciaccafava

Romain - you were so right.  A little less calculating to be done and I 
got the result I wished.  For anyone interested here's the function I'm 
using to determine how much time there is until a cookie expires.  The 
cookie in question contains the expiration datetime that was used to 
create a paired cookie.


function GetTimeLeft($applid)
{
   if (isset($_COOKIE[$applid]))
   {
  if (isset($_COOKIE[$applid."expire"]))
  {
 $curr_time = new datetime();
 $cookietime = $_COOKIE[$applid."expire"];
 $exp_time = new datetime();
 $exp_time->setTimeStamp($cookietime);
 $diff = $curr_time->diff($exp_time);
 $days = $diff->format("%d");
 $days = ($days > 1) ? "$days days": ($days == 1) ?
   "$days day" : '';
 $hms = $diff->format("%h:%i:%s");
 return "Time left: $days $hms";
  }
  else
 return '?';
   }
   else
  return '0';
}



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



Re: [PHP] PHP Fatal error: Call to undefined function ()

2013-10-07 Thread Stuart Dallas
On 7 Oct 2013, at 14:34, Michael Alaimo  wrote:

> On Mon, Oct 7, 2013 at 9:29 AM, Stuart Dallas  wrote:
>> On 7 Oct 2013, at 14:24, Michael Alaimo  wrote:
>> 
>> > We have a server that gets a large number of requests each month.
>> >
>> > After a period of time I began to see this error in our error logs this
>> > weekend.
>> >
>> > PHP Fatal error:  Call to undefined function ()
>> >
>> > It does not reference a function, so I found it odd.  It did give a line to
>> > a function with array_merge on it.
>> >
>> > Has anyone seen this in the apache error logs?  We are using PHP 5.3.3.
>> 
>> Show us the line, and a few lines around it.
> public static function getInfo($params = array())
> {
> $results = array();
> 
> $url = 'http://google.com';
> 
> 
>  $props = array
> (
>'key'=> Yii::app()->params['param1'],
> 's'=> Yii::app()->params['param2']
> );
> 
> if (!empty($params))
> {
> $props = array_merge($props, $params);
> 
> $url = $url . http_build_query($props, '', '/');
> 
> 
> It may be possible that params has unsafe data in it.  The previous dev did 
> not validate the data passed in via get.
> 
> The code populating params looks like:
> 
> $params = array
> (
> 'd' => $_GET['d'],
> );
> 
> $job = Job::getInfo($params);

My best guess is that either $props or $params contain a function reference or 
similar construct. Examine their contents with var_dump.

As a check you could expand out the effect of array_merge and see if you still 
get the same with a PHP implementation.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] PHP Fatal error: Call to undefined function ()

2013-10-07 Thread Michael Alaimo
public static function getInfo($params = array())
{
$results = array();

$url = 'http://google.com';


 $props = array
(
   'key'=> Yii::app()->params['param1'],
's'=> Yii::app()->params['param2']
);

if (!empty($params))
{
$props = array_merge($props, $params);

$url = $url . http_build_query($props, '', '/');


It may be possible that params has unsafe data in it.  The previous dev did
not validate the data passed in via get.

The code populating params looks like:

$params = array
(
'd' => $_GET['d'],
);

$job = Job::getInfo($params);



On Mon, Oct 7, 2013 at 9:29 AM, Stuart Dallas  wrote:

> On 7 Oct 2013, at 14:24, Michael Alaimo  wrote:
>
> > We have a server that gets a large number of requests each month.
> >
> > After a period of time I began to see this error in our error logs this
> > weekend.
> >
> > PHP Fatal error:  Call to undefined function ()
> >
> > It does not reference a function, so I found it odd.  It did give a line
> to
> > a function with array_merge on it.
> >
> > Has anyone seen this in the apache error logs?  We are using PHP 5.3.3.
>
> Show us the line, and a few lines around it.
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>


Re: [PHP] PHP Fatal error: Call to undefined function ()

2013-10-07 Thread Stuart Dallas
On 7 Oct 2013, at 14:24, Michael Alaimo  wrote:

> We have a server that gets a large number of requests each month.
> 
> After a period of time I began to see this error in our error logs this
> weekend.
> 
> PHP Fatal error:  Call to undefined function ()
> 
> It does not reference a function, so I found it odd.  It did give a line to
> a function with array_merge on it.
> 
> Has anyone seen this in the apache error logs?  We are using PHP 5.3.3.

Show us the line, and a few lines around it.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



[PHP] PHP Fatal error: Call to undefined function ()

2013-10-07 Thread Michael Alaimo
We have a server that gets a large number of requests each month.

After a period of time I began to see this error in our error logs this
weekend.

PHP Fatal error:  Call to undefined function ()

It does not reference a function, so I found it odd.  It did give a line to
a function with array_merge on it.

Has anyone seen this in the apache error logs?  We are using PHP 5.3.3.

Mike


Re: [PHP] date time problem

2013-10-06 Thread Romain CIACCAFAVA
An easier way to do that would be using the diff() method of a DateTime object 
on another.

Regards
Romain Ciaccafava

> Le 7 oct. 2013 à 03:10, Jim Giner  a écrit :
> 
>> On 10/6/2013 7:55 PM, Ashley Sheridan wrote:
>>> On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:
>>> 
>>> Jim,
>>> 
>>> The date method takes in a timestamp (not seconds away).
>>> 
>>> You have the seconds, you will need to manually convert those seconds to
>>> what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
>>> 
>>> Aziz
>>> 
>>> 
>>> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee 
>>> wrote:
>>> 
>>>> Its so freaky
>>>> 
>>>> Best Regards
>>>> Farzan Dalaee
>>>> 
>>>>>> On Oct 7, 2013, at 2:29, Jim Giner  wrote:
>>>>>> 
>>>>>> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>>>>>> Try this please
>>>>>> 
>>>>>>  gmdate("H:i:s", $diff%86400)
>>>>>> 
>>>>>> Best Regards
>>>>>> Farzan Dalaee
>>>>>> 
>>>>>>>> On Oct 7, 2013, at 2:12, Jim Giner 
>>>> wrote:
>>>>>>>> 
>>>>>>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>>>>>>>> You should use  gmdate() if you want to how many hours left to expire
>>>>>>>> $time_left = gmdate("H:i:s",$diff);
>>>>>>>> 
>>>>>>>> Best Regards
>>>>>>>> Farzan Dalaee
>>>>>>>> 
>>>>>>>>> On Oct 7, 2013, at 1:49, Jim Giner 
>>>> wrote:
>>>>>>>>> 
>>>>>>>>> I always hate dealing with date/time stuff in php - never get it
>>>> even close until an hour or two goes by
>>>>>>>>> 
>>>>>>>>> anyway
>>>>>>>>> 
>>>>>>>>> I have this:
>>>>>>>>> 
>>>>>>>>> // get two timestamp values
>>>>>>>>> $exp_time = $_COOKIE[$applid."expire"];
>>>>>>>>> $curr_time = time();
>>>>>>>>> // get the difference
>>>>>>>>> $diff = $exp_time - $curr_time;
>>>>>>>>> // produce a display time of the diff
>>>>>>>>> $time_left = date("h:i:s",$diff);
>>>>>>>>> 
>>>>>>>>> Currently the results are:
>>>>>>>>> exp_time is 06:55:07
>>>>>>>>> curr_time is 06:12:03
>>>>>>>>> the diff is 2584
>>>>>>>>> All of these are correct.
>>>>>>>>> 
>>>>>>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>>>>>>>>> 
>>>>>>>>> So - where is the hour value of '07' coming from?? And how do I get
>>>> this right?
>>>>>>>>> 
>>>>>>>>> --
>>>>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>> Thanks for the quick response, but why do I want to show the time in
>>>> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>>>>  Now instead of a 7 for hours I have a 12.
>>>>>>> 
>>>>>>> exp 07:34:52
>>>>>>> curr 06:40:14
>>>>>>> diff 3158
>>>>>>> left is 12:52:38
>>>>>>> 
>>>>>>> The 52:38 is the correct value, but not the 12.
>>>>>>> 
>>>>>>> --
>>>>>>> PHP General Mailing List (http://www.php.net/)
>>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>> Doesn't work either.
>>>>> 
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
>> Aziz, please try not to top post :)
>> 
>> It's true that the date() function takes in a timestamp as its argument,
>> but a timestamp is a number representing the number of seconds since
>> 00:00:00 1st January 1970, so passing in a very small number of seconds
>> is perfectly valid.
>> 
>> The only thing that would account for the 7 hours difference is the time
>> zone, which would also be part of the timestamp.
>> http://en.wikipedia.org/wiki/Unix_time gives more details.
>> 
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
> Thanks Ash, but the previous (top) post explained my dilemma just as you have 
> done here.  My attempt to use a function to avoid "doing the math" has now 
> been resolved.  Guess I'll have to do it the old-fashioned way.
> 
> -- 
> 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] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 7:55 PM, Ashley Sheridan wrote:

On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:


Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee wrote:


Its so freaky

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:29, Jim Giner  wrote:


On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
Try this please

  gmdate("H:i:s", $diff%86400)

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:12, Jim Giner 

wrote:


On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner 

wrote:


I always hate dealing with date/time stuff in php - never get it

even close until an hour or two goes by


anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get

this right?


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

Thanks for the quick response, but why do I want to show the time in

GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
  Now instead of a 7 for hours I have a 12.


exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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

Doesn't work either.

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






Aziz, please try not to top post :)

It's true that the date() function takes in a timestamp as its argument,
but a timestamp is a number representing the number of seconds since
00:00:00 1st January 1970, so passing in a very small number of seconds
is perfectly valid.

The only thing that would account for the 7 hours difference is the time
zone, which would also be part of the timestamp.
http://en.wikipedia.org/wiki/Unix_time gives more details.

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



Thanks Ash, but the previous (top) post explained my dilemma just as you 
have done here.  My attempt to use a function to avoid "doing the math" 
has now been resolved.  Guess I'll have to do it the old-fashioned way.


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



Re: [PHP] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 7:40 PM, Aziz Saleh wrote:

The resulting subtraction is not a valid timestamp, but rather the
difference between the two timestamps in seconds . The resulting diff can
be 1 if the timestamps are 1 seconds apart. The
link<http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php>Jonathan
sent out contains functions that does the division for you with
results. Another link you can check out:

http://stackoverflow.com/a/9143387/1935500



On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner wrote:


Look at my code. The inputs are all timestamps so date should work, no?
My question why am i getting an hour value in this case?

jg


On Oct 6, 2013, at 7:14 PM, Aziz Saleh  wrote:

Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee wrote:


Its so freaky

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:29, Jim Giner 

wrote:



On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
Try this please

  gmdate("H:i:s", $diff%86400)

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:12, Jim Giner 

wrote:


On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner 

wrote:


I always hate dealing with date/time stuff in php - never get it

even close until an hour or two goes by


anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get

this right?


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

Thanks for the quick response, but why do I want to show the time in

GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
  Now instead of a 7 for hours I have a 12.


exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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

Doesn't work either.

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








Good Point!  I never looked at it that way.  I guess the Date function 
can't be relied on in that case.  So now I'll have to calculate my time 
in a mathematical way instead of letting Date translate it for me.


Thanks!



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



Re: [PHP] date time problem

2013-10-06 Thread Ashley Sheridan
On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote:

> Jim,
> 
> The date method takes in a timestamp (not seconds away).
> 
> You have the seconds, you will need to manually convert those seconds to
> what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
> 
> Aziz
> 
> 
> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee wrote:
> 
> > Its so freaky
> >
> > Best Regards
> > Farzan Dalaee
> >
> > > On Oct 7, 2013, at 2:29, Jim Giner  wrote:
> > >
> > >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
> > >> Try this please
> > >>
> > >>  gmdate("H:i:s", $diff%86400)
> > >>
> > >> Best Regards
> > >> Farzan Dalaee
> > >>
> > >>>> On Oct 7, 2013, at 2:12, Jim Giner 
> > wrote:
> > >>>>
> > >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
> > >>>> You should use  gmdate() if you want to how many hours left to expire
> > >>>> $time_left = gmdate("H:i:s",$diff);
> > >>>>
> > >>>> Best Regards
> > >>>> Farzan Dalaee
> > >>>>
> > >>>>> On Oct 7, 2013, at 1:49, Jim Giner 
> > wrote:
> > >>>>>
> > >>>>> I always hate dealing with date/time stuff in php - never get it
> > even close until an hour or two goes by
> > >>>>>
> > >>>>> anyway
> > >>>>>
> > >>>>> I have this:
> > >>>>>
> > >>>>> // get two timestamp values
> > >>>>> $exp_time = $_COOKIE[$applid."expire"];
> > >>>>> $curr_time = time();
> > >>>>> // get the difference
> > >>>>> $diff = $exp_time - $curr_time;
> > >>>>> // produce a display time of the diff
> > >>>>> $time_left = date("h:i:s",$diff);
> > >>>>>
> > >>>>> Currently the results are:
> > >>>>> exp_time is 06:55:07
> > >>>>> curr_time is 06:12:03
> > >>>>> the diff is 2584
> > >>>>> All of these are correct.
> > >>>>>
> > >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
> > >>>>>
> > >>>>> So - where is the hour value of '07' coming from?? And how do I get
> > this right?
> > >>>>>
> > >>>>> --
> > >>>>> PHP General Mailing List (http://www.php.net/)
> > >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
> > >>> Thanks for the quick response, but why do I want to show the time in
> > GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
> >  Now instead of a 7 for hours I have a 12.
> > >>>
> > >>> exp 07:34:52
> > >>> curr 06:40:14
> > >>> diff 3158
> > >>> left is 12:52:38
> > >>>
> > >>> The 52:38 is the correct value, but not the 12.
> > >>>
> > >>> --
> > >>> PHP General Mailing List (http://www.php.net/)
> > >>> To unsubscribe, visit: http://www.php.net/unsub.php
> > > Doesn't work either.
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >


Aziz, please try not to top post :)

It's true that the date() function takes in a timestamp as its argument,
but a timestamp is a number representing the number of seconds since
00:00:00 1st January 1970, so passing in a very small number of seconds
is perfectly valid.

The only thing that would account for the 7 hours difference is the time
zone, which would also be part of the timestamp.
http://en.wikipedia.org/wiki/Unix_time gives more details.

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




Re: [PHP] date time problem

2013-10-06 Thread Aziz Saleh
The resulting subtraction is not a valid timestamp, but rather the
difference between the two timestamps in seconds . The resulting diff can
be 1 if the timestamps are 1 seconds apart. The
link<http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php>Jonathan
sent out contains functions that does the division for you with
results. Another link you can check out:

http://stackoverflow.com/a/9143387/1935500



On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner wrote:

> Look at my code. The inputs are all timestamps so date should work, no?
> My question why am i getting an hour value in this case?
>
> jg
>
>
> On Oct 6, 2013, at 7:14 PM, Aziz Saleh  wrote:
>
> Jim,
>
> The date method takes in a timestamp (not seconds away).
>
> You have the seconds, you will need to manually convert those seconds to
> what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
>
> Aziz
>
>
> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee wrote:
>
>> Its so freaky
>>
>> Best Regards
>> Farzan Dalaee
>>
>> > On Oct 7, 2013, at 2:29, Jim Giner 
>> wrote:
>> >
>> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>> >> Try this please
>> >>
>> >>  gmdate("H:i:s", $diff%86400)
>> >>
>> >> Best Regards
>> >> Farzan Dalaee
>> >>
>> >>>> On Oct 7, 2013, at 2:12, Jim Giner 
>> wrote:
>> >>>>
>> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>> >>>> You should use  gmdate() if you want to how many hours left to expire
>> >>>> $time_left = gmdate("H:i:s",$diff);
>> >>>>
>> >>>> Best Regards
>> >>>> Farzan Dalaee
>> >>>>
>> >>>>> On Oct 7, 2013, at 1:49, Jim Giner 
>> wrote:
>> >>>>>
>> >>>>> I always hate dealing with date/time stuff in php - never get it
>> even close until an hour or two goes by
>> >>>>>
>> >>>>> anyway
>> >>>>>
>> >>>>> I have this:
>> >>>>>
>> >>>>> // get two timestamp values
>> >>>>> $exp_time = $_COOKIE[$applid."expire"];
>> >>>>> $curr_time = time();
>> >>>>> // get the difference
>> >>>>> $diff = $exp_time - $curr_time;
>> >>>>> // produce a display time of the diff
>> >>>>> $time_left = date("h:i:s",$diff);
>> >>>>>
>> >>>>> Currently the results are:
>> >>>>> exp_time is 06:55:07
>> >>>>> curr_time is 06:12:03
>> >>>>> the diff is 2584
>> >>>>> All of these are correct.
>> >>>>>
>> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>> >>>>>
>> >>>>> So - where is the hour value of '07' coming from?? And how do I get
>> this right?
>> >>>>>
>> >>>>> --
>> >>>>> PHP General Mailing List (http://www.php.net/)
>> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>> Thanks for the quick response, but why do I want to show the time in
>> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>>  Now instead of a 7 for hours I have a 12.
>> >>>
>> >>> exp 07:34:52
>> >>> curr 06:40:14
>> >>> diff 3158
>> >>> left is 12:52:38
>> >>>
>> >>> The 52:38 is the correct value, but not the 12.
>> >>>
>> >>> --
>> >>> PHP General Mailing List (http://www.php.net/)
>> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>> > Doesn't work either.
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>>
>
>


Re: [PHP] date time problem

2013-10-06 Thread Jim Giner
Look at my code. The inputs are all timestamps so date should work, no?
My question why am i getting an hour value in this case?

jg


On Oct 6, 2013, at 7:14 PM, Aziz Saleh  wrote:

> Jim,
> 
> The date method takes in a timestamp (not seconds away).
> 
> You have the seconds, you will need to manually convert those seconds to what 
> you desire (minutes = seconds / 60), (hours = minutes / 60), etc..
> 
> Aziz
> 
> 
> On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee  wrote:
>> Its so freaky
>> 
>> Best Regards
>> Farzan Dalaee
>> 
>> > On Oct 7, 2013, at 2:29, Jim Giner  wrote:
>> >
>> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>> >> Try this please
>> >>
>> >>  gmdate("H:i:s", $diff%86400)
>> >>
>> >> Best Regards
>> >> Farzan Dalaee
>> >>
>> >>>> On Oct 7, 2013, at 2:12, Jim Giner  wrote:
>> >>>>
>> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>> >>>> You should use  gmdate() if you want to how many hours left to expire
>> >>>> $time_left = gmdate("H:i:s",$diff);
>> >>>>
>> >>>> Best Regards
>> >>>> Farzan Dalaee
>> >>>>
>> >>>>> On Oct 7, 2013, at 1:49, Jim Giner  
>> >>>>> wrote:
>> >>>>>
>> >>>>> I always hate dealing with date/time stuff in php - never get it even 
>> >>>>> close until an hour or two goes by
>> >>>>>
>> >>>>> anyway
>> >>>>>
>> >>>>> I have this:
>> >>>>>
>> >>>>> // get two timestamp values
>> >>>>> $exp_time = $_COOKIE[$applid."expire"];
>> >>>>> $curr_time = time();
>> >>>>> // get the difference
>> >>>>> $diff = $exp_time - $curr_time;
>> >>>>> // produce a display time of the diff
>> >>>>> $time_left = date("h:i:s",$diff);
>> >>>>>
>> >>>>> Currently the results are:
>> >>>>> exp_time is 06:55:07
>> >>>>> curr_time is 06:12:03
>> >>>>> the diff is 2584
>> >>>>> All of these are correct.
>> >>>>>
>> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>> >>>>>
>> >>>>> So - where is the hour value of '07' coming from?? And how do I get 
>> >>>>> this right?
>> >>>>>
>> >>>>> --
>> >>>>> PHP General Mailing List (http://www.php.net/)
>> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>> Thanks for the quick response, but why do I want to show the time in 
>> >>> GMT?  However, I did try it, changing the 'time_left' calc to use 
>> >>> "gmdate".  Now instead of a 7 for hours I have a 12.
>> >>>
>> >>> exp 07:34:52
>> >>> curr 06:40:14
>> >>> diff 3158
>> >>> left is 12:52:38
>> >>>
>> >>> The 52:38 is the correct value, but not the 12.
>> >>>
>> >>> --
>> >>> PHP General Mailing List (http://www.php.net/)
>> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>> > Doesn't work either.
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
> 


Re: [PHP] date time problem

2013-10-06 Thread Aziz Saleh
Jim,

The date method takes in a timestamp (not seconds away).

You have the seconds, you will need to manually convert those seconds to
what you desire (minutes = seconds / 60), (hours = minutes / 60), etc..

Aziz


On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee wrote:

> Its so freaky
>
> Best Regards
> Farzan Dalaee
>
> > On Oct 7, 2013, at 2:29, Jim Giner  wrote:
> >
> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
> >> Try this please
> >>
> >>  gmdate("H:i:s", $diff%86400)
> >>
> >> Best Regards
> >> Farzan Dalaee
> >>
> >>>> On Oct 7, 2013, at 2:12, Jim Giner 
> wrote:
> >>>>
> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
> >>>> You should use  gmdate() if you want to how many hours left to expire
> >>>> $time_left = gmdate("H:i:s",$diff);
> >>>>
> >>>> Best Regards
> >>>> Farzan Dalaee
> >>>>
> >>>>> On Oct 7, 2013, at 1:49, Jim Giner 
> wrote:
> >>>>>
> >>>>> I always hate dealing with date/time stuff in php - never get it
> even close until an hour or two goes by
> >>>>>
> >>>>> anyway
> >>>>>
> >>>>> I have this:
> >>>>>
> >>>>> // get two timestamp values
> >>>>> $exp_time = $_COOKIE[$applid."expire"];
> >>>>> $curr_time = time();
> >>>>> // get the difference
> >>>>> $diff = $exp_time - $curr_time;
> >>>>> // produce a display time of the diff
> >>>>> $time_left = date("h:i:s",$diff);
> >>>>>
> >>>>> Currently the results are:
> >>>>> exp_time is 06:55:07
> >>>>> curr_time is 06:12:03
> >>>>> the diff is 2584
> >>>>> All of these are correct.
> >>>>>
> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
> >>>>>
> >>>>> So - where is the hour value of '07' coming from?? And how do I get
> this right?
> >>>>>
> >>>>> --
> >>>>> PHP General Mailing List (http://www.php.net/)
> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>> Thanks for the quick response, but why do I want to show the time in
> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>  Now instead of a 7 for hours I have a 12.
> >>>
> >>> exp 07:34:52
> >>> curr 06:40:14
> >>> diff 3158
> >>> left is 12:52:38
> >>>
> >>> The 52:38 is the correct value, but not the 12.
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> > Doesn't work either.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


Re: [PHP] date time problem

2013-10-06 Thread Jonathan Sundquist
This should help you out
http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php
On Oct 6, 2013 6:07 PM, "Farzan Dalaee"  wrote:

> Its so freaky
>
> Best Regards
> Farzan Dalaee
>
> > On Oct 7, 2013, at 2:29, Jim Giner  wrote:
> >
> >> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
> >> Try this please
> >>
> >>  gmdate("H:i:s", $diff%86400)
> >>
> >> Best Regards
> >> Farzan Dalaee
> >>
> >>>> On Oct 7, 2013, at 2:12, Jim Giner 
> wrote:
> >>>>
> >>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
> >>>> You should use  gmdate() if you want to how many hours left to expire
> >>>> $time_left = gmdate("H:i:s",$diff);
> >>>>
> >>>> Best Regards
> >>>> Farzan Dalaee
> >>>>
> >>>>> On Oct 7, 2013, at 1:49, Jim Giner 
> wrote:
> >>>>>
> >>>>> I always hate dealing with date/time stuff in php - never get it
> even close until an hour or two goes by
> >>>>>
> >>>>> anyway
> >>>>>
> >>>>> I have this:
> >>>>>
> >>>>> // get two timestamp values
> >>>>> $exp_time = $_COOKIE[$applid."expire"];
> >>>>> $curr_time = time();
> >>>>> // get the difference
> >>>>> $diff = $exp_time - $curr_time;
> >>>>> // produce a display time of the diff
> >>>>> $time_left = date("h:i:s",$diff);
> >>>>>
> >>>>> Currently the results are:
> >>>>> exp_time is 06:55:07
> >>>>> curr_time is 06:12:03
> >>>>> the diff is 2584
> >>>>> All of these are correct.
> >>>>>
> >>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
> >>>>>
> >>>>> So - where is the hour value of '07' coming from?? And how do I get
> this right?
> >>>>>
> >>>>> --
> >>>>> PHP General Mailing List (http://www.php.net/)
> >>>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>> Thanks for the quick response, but why do I want to show the time in
> GMT?  However, I did try it, changing the 'time_left' calc to use "gmdate".
>  Now instead of a 7 for hours I have a 12.
> >>>
> >>> exp 07:34:52
> >>> curr 06:40:14
> >>> diff 3158
> >>> left is 12:52:38
> >>>
> >>> The 52:38 is the correct value, but not the 12.
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> > Doesn't work either.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


Re: [PHP] date time problem

2013-10-06 Thread Farzan Dalaee
Its so freaky 

Best Regards
Farzan Dalaee

> On Oct 7, 2013, at 2:29, Jim Giner  wrote:
> 
>> On 10/6/2013 6:49 PM, Farzan Dalaee wrote:
>> Try this please
>> 
>>  gmdate("H:i:s", $diff%86400)
>> 
>> Best Regards
>> Farzan Dalaee
>> 
>>>> On Oct 7, 2013, at 2:12, Jim Giner  wrote:
>>>> 
>>>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>>>> You should use  gmdate() if you want to how many hours left to expire
>>>> $time_left = gmdate("H:i:s",$diff);
>>>> 
>>>> Best Regards
>>>> Farzan Dalaee
>>>> 
>>>>> On Oct 7, 2013, at 1:49, Jim Giner  wrote:
>>>>> 
>>>>> I always hate dealing with date/time stuff in php - never get it even 
>>>>> close until an hour or two goes by
>>>>> 
>>>>> anyway
>>>>> 
>>>>> I have this:
>>>>> 
>>>>> // get two timestamp values
>>>>> $exp_time = $_COOKIE[$applid."expire"];
>>>>> $curr_time = time();
>>>>> // get the difference
>>>>> $diff = $exp_time - $curr_time;
>>>>> // produce a display time of the diff
>>>>> $time_left = date("h:i:s",$diff);
>>>>> 
>>>>> Currently the results are:
>>>>> exp_time is 06:55:07
>>>>> curr_time is 06:12:03
>>>>> the diff is 2584
>>>>> All of these are correct.
>>>>> 
>>>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>>>>> 
>>>>> So - where is the hour value of '07' coming from?? And how do I get this 
>>>>> right?
>>>>> 
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> Thanks for the quick response, but why do I want to show the time in GMT?  
>>> However, I did try it, changing the 'time_left' calc to use "gmdate".  Now 
>>> instead of a 7 for hours I have a 12.
>>> 
>>> exp 07:34:52
>>> curr 06:40:14
>>> diff 3158
>>> left is 12:52:38
>>> 
>>> The 52:38 is the correct value, but not the 12.
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
> Doesn't work either.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


Re: [PHP] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 6:49 PM, Farzan Dalaee wrote:

Try this please

  gmdate("H:i:s", $diff%86400)

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 2:12, Jim Giner  wrote:


On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner  wrote:

I always hate dealing with date/time stuff in php - never get it even close 
until an hour or two goes by

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get this right?

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

Thanks for the quick response, but why do I want to show the time in GMT?  However, I did 
try it, changing the 'time_left' calc to use "gmdate".  Now instead of a 7 for 
hours I have a 12.

exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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




Doesn't work either.

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



[PHP] After a PHP script timeout, Apache logs the error but may not cleanly exit the script

2013-10-06 Thread Meta Seller Admin
Hi. I'm wondering if anyone can help with this.

We're using PHP and Apache, hosted on a dedicated server running
Debian Linux. The specific versions in each case are mostly
immaterial, as this problem has been around since Debian 6, and is
still present in Debian 7; in the meantime we've been using the latest
versions of all packages.

We're having problems with PHP script timeouts, which although rare,
are behaving erratically and causing severe problems when they do
occur.

The timeouts are always recorded in the Apache log, and sometimes the
script and everything else may execute/terminate correctly, but often,
various failures may be observed, such as:

* timeouts not registered back to PHP - the script may not terminate
as expected (the function registered with register_shutdown_function()
- see code example below - may not be called);

* after a timeout, Apache may run in the background indefinitely,
using up CPU resources in one core;

* Apache may fail altogether - no further requests serviced - Apache
must be restarted.

The exact cause of the fault has not been found. It is reproducible on
all servers we deploy to.

Example PHP script:

//...
function _on_shutdown()
{
if (connection_status() & CONNECTION_TIMEOUT)
{
echo 'ERROR: TIMEOUT!';
//Do something else...
}
exit;
}
register_shutdown_function('_on_shutdown');
//...more code here...
//(various potentially long running scripts which may timeout)


The above was also posted here:
http://serverfault.com/questions/542045/after-a-php-script-timeout-apache-logs-the-error-but-may-not-cleanly-exit-the-s

Ric.

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



Re: [PHP] date time problem

2013-10-06 Thread Farzan Dalaee
Try this please

 gmdate("H:i:s", $diff%86400) 

Best Regards
Farzan Dalaee

> On Oct 7, 2013, at 2:12, Jim Giner  wrote:
> 
>> On 10/6/2013 6:36 PM, Farzan Dalaee wrote:
>> You should use  gmdate() if you want to how many hours left to expire
>> $time_left = gmdate("H:i:s",$diff);
>> 
>> Best Regards
>> Farzan Dalaee
>> 
>>> On Oct 7, 2013, at 1:49, Jim Giner  wrote:
>>> 
>>> I always hate dealing with date/time stuff in php - never get it even close 
>>> until an hour or two goes by
>>> 
>>> anyway
>>> 
>>> I have this:
>>> 
>>> // get two timestamp values
>>> $exp_time = $_COOKIE[$applid."expire"];
>>> $curr_time = time();
>>> // get the difference
>>> $diff = $exp_time - $curr_time;
>>> // produce a display time of the diff
>>> $time_left = date("h:i:s",$diff);
>>> 
>>> Currently the results are:
>>> exp_time is 06:55:07
>>> curr_time is 06:12:03
>>> the diff is 2584
>>> All of these are correct.
>>> 
>>> BUT time_left is 07:43:04 when it should be only "00:43:04".
>>> 
>>> So - where is the hour value of '07' coming from?? And how do I get this 
>>> right?
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
> Thanks for the quick response, but why do I want to show the time in GMT?  
> However, I did try it, changing the 'time_left' calc to use "gmdate".  Now 
> instead of a 7 for hours I have a 12.
> 
> exp 07:34:52
> curr 06:40:14
> diff 3158
> left is 12:52:38
> 
> The 52:38 is the correct value, but not the 12.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


Re: [PHP] date time problem

2013-10-06 Thread Jim Giner

On 10/6/2013 6:36 PM, Farzan Dalaee wrote:

You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee


On Oct 7, 2013, at 1:49, Jim Giner  wrote:

I always hate dealing with date/time stuff in php - never get it even close 
until an hour or two goes by

anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get this right?

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



Thanks for the quick response, but why do I want to show the time in 
GMT?  However, I did try it, changing the 'time_left' calc to use 
"gmdate".  Now instead of a 7 for hours I have a 12.


exp 07:34:52
curr 06:40:14
diff 3158
left is 12:52:38

The 52:38 is the correct value, but not the 12.

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



Re: [PHP] date time problem

2013-10-06 Thread Farzan Dalaee
You should use  gmdate() if you want to how many hours left to expire
$time_left = gmdate("H:i:s",$diff);

Best Regards
Farzan Dalaee

> On Oct 7, 2013, at 1:49, Jim Giner  wrote:
> 
> I always hate dealing with date/time stuff in php - never get it even close 
> until an hour or two goes by
> 
> anyway
> 
> I have this:
> 
> // get two timestamp values
> $exp_time = $_COOKIE[$applid."expire"];
> $curr_time = time();
> // get the difference
> $diff = $exp_time - $curr_time;
> // produce a display time of the diff
> $time_left = date("h:i:s",$diff);
> 
> Currently the results are:
> exp_time is 06:55:07
> curr_time is 06:12:03
> the diff is 2584
> All of these are correct.
> 
> BUT time_left is 07:43:04 when it should be only "00:43:04".
> 
> So - where is the hour value of '07' coming from?? And how do I get this 
> right?
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


[PHP] date time problem

2013-10-06 Thread Jim Giner
I always hate dealing with date/time stuff in php - never get it even 
close until an hour or two goes by


anyway

I have this:

// get two timestamp values
$exp_time = $_COOKIE[$applid."expire"];
$curr_time = time();
// get the difference
$diff = $exp_time - $curr_time;
// produce a display time of the diff
$time_left = date("h:i:s",$diff);

Currently the results are:
exp_time is 06:55:07
curr_time is 06:12:03
the diff is 2584
All of these are correct.

BUT time_left is 07:43:04 when it should be only "00:43:04".

So - where is the hour value of '07' coming from?? And how do I get this 
right?


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



Re: [PHP] Algorithm Help

2013-10-03 Thread Nickolas Whiting
Round Robin algorithm should solve this and is a fairly quick alogrithm ...
http://en.wikipedia.org/wiki/Round-robin

An example can be found
http://forrst.com/posts/PHP_Round_Robin_Algorithm-2zm


On Tue, Oct 1, 2013 at 2:51 PM, Floyd Resler  wrote:

> Here's my task: A group of kids is going to be staying with different host
> families throughout the next 8 months.  The number of kids staying with a
> host family can range from 2 to 10.  When deciding which kids should stay
> together at a host family, the idea is for the system to put together kids
> who have stayed with each other the least on past weekends.  So, if a host
> family can keep 5 kids, then the group of 5 kids who have stayed together
> the least will be chosen.
>
> I can't think of an easy, quick way to accomplish this.  I've tried
> various approaches that have resulted in a lot of coding and being very
> slow.  My idea was to give each group of kids a score and the lowest score
> is the group that is selected.  However, this approach wound of iterating
> through several arrays several times which was really slow.  Does anyone
> have any ideas on this puzzle?
>
> Thanks!
> Floyd
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Nickolas Whiting
Freelance Consultant


Re: [PHP] Algorithm Help

2013-10-03 Thread Floyd Resler


On Oct 2, 2013, at 6:23 PM, Tamara Temple  wrote:

> 
> On Oct 2, 2013, at 9:05 AM, Marc Guay  wrote:
> 
>> If you have the technology handy, it could also just be easier to wipe
>> the children's memories after each stay.
>> 
>> Marc
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
> 
> Well played! (.. eying the black suit…. "What's that funny stick you're 
> hol….")
> 
> 
> 

I love it! Our director loved it too!  Too funny!

Thanks!
Floyd



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



Re: [PHP] Algorithm Help

2013-10-02 Thread Tamara Temple

On Oct 2, 2013, at 9:05 AM, Marc Guay  wrote:

> If you have the technology handy, it could also just be easier to wipe
> the children's memories after each stay.
> 
> Marc
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Well played! (.. eying the black suit…. "What's that funny stick you're hol….")


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



Re: [PHP] Algorithm Help

2013-10-02 Thread Marc Guay
If you have the technology handy, it could also just be easier to wipe
the children's memories after each stay.

Marc

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



Re: [PHP] Algorithm Help

2013-10-02 Thread Floyd Resler


On Oct 2, 2013, at 9:51 AM, Tamara Temple  wrote:

> 
> On Oct 1, 2013, at 1:51 PM, Floyd Resler  wrote:
> 
>> Here's my task: A group of kids is going to be staying with different host 
>> families throughout the next 8 months.  The number of kids staying with a 
>> host family can range from 2 to 10.  When deciding which kids should stay 
>> together at a host family, the idea is for the system to put together kids 
>> who have stayed with each other the least on past weekends.  So, if a host 
>> family can keep 5 kids, then the group of 5 kids who have stayed together 
>> the least will be chosen.
>> 
>> I can't think of an easy, quick way to accomplish this.  I've tried various 
>> approaches that have resulted in a lot of coding and being very slow.  My 
>> idea was to give each group of kids a score and the lowest score is the 
>> group that is selected.  However, this approach wound of iterating through 
>> several arrays several times which was really slow.  Does anyone have any 
>> ideas on this puzzle?
>> 
>> Thanks!
>> Floyd
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
> 
> While definitely a tempting coding exercise, I just want to say that if this 
> is urgent in any way, shuffling cards with the kids' names on them by hand 
> might just be faster and less frustrating :)
> 
> OTOH, if this is something you're going to have to figure out week after 
> week, then a software solution might be handy.
> 
> This is also not an *easy* problem to solve; there isn't a simple approach to 
> optimizing this sort of thing because you're building a net between all the 
> various kids based on past stays, in addition to the constraints of host 
> family  capacity. Thus your previous code attempts might in fact be the end 
> result.
> 
> Obviously, structuring the data is the key here.
> 
> I'm thinking of 3 primary models: Kids, Hosts, and Stays.
> 
> Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs 
> to have joining tables with Kids and Hosts.
> 
> A Stay will have one Host, and have many Kids and a date.
> 
> The algorithm then needs to make the graph where it can pull out the number 
> of times any particular kid has stayed with another, looking something like 
> this:
> 
> Amy:
>   Ben: 10
>   Jill: 3
>   Carlos: 7
>   Chen: 2
> Ben:
>   Amy: 10
>   Jill: 5
>   Carlos: 8
>   Chen: 3
> Jill:
>   … and so on
> 
> Then you be able to pull through that graph and find the smallest number of 
> stays for each kid.
> 
> Not simple, but I hope this helps.
> 
> 

That's the only approach I could think of.  I may have to tell the director it 
may be a bit slow but at least she won't have to do it by hand!

Thanks!
Floyd


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



Re: [PHP] Algorithm Help

2013-10-02 Thread Serge Fonville
It also depends on the amount of kids, families and stays.

If the numbers are low, by hand may be a lot easier and faster

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl


2013/10/2 Tamara Temple 

>
> On Oct 1, 2013, at 1:51 PM, Floyd Resler  wrote:
>
> > Here's my task: A group of kids is going to be staying with different
> host families throughout the next 8 months.  The number of kids staying
> with a host family can range from 2 to 10.  When deciding which kids should
> stay together at a host family, the idea is for the system to put together
> kids who have stayed with each other the least on past weekends.  So, if a
> host family can keep 5 kids, then the group of 5 kids who have stayed
> together the least will be chosen.
> >
> > I can't think of an easy, quick way to accomplish this.  I've tried
> various approaches that have resulted in a lot of coding and being very
> slow.  My idea was to give each group of kids a score and the lowest score
> is the group that is selected.  However, this approach wound of iterating
> through several arrays several times which was really slow.  Does anyone
> have any ideas on this puzzle?
> >
> > Thanks!
> > Floyd
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> While definitely a tempting coding exercise, I just want to say that if
> this is urgent in any way, shuffling cards with the kids' names on them by
> hand might just be faster and less frustrating :)
>
> OTOH, if this is something you're going to have to figure out week after
> week, then a software solution might be handy.
>
> This is also not an *easy* problem to solve; there isn't a simple approach
> to optimizing this sort of thing because you're building a net between all
> the various kids based on past stays, in addition to the constraints of
> host family  capacity. Thus your previous code attempts might in fact be
> the end result.
>
> Obviously, structuring the data is the key here.
>
> I'm thinking of 3 primary models: Kids, Hosts, and Stays.
>
> Kids and Hosts seem pretty obvious. Stays is the interesing model, and
> needs to have joining tables with Kids and Hosts.
>
> A Stay will have one Host, and have many Kids and a date.
>
> The algorithm then needs to make the graph where it can pull out the
> number of times any particular kid has stayed with another, looking
> something like this:
>
> Amy:
>Ben: 10
>Jill: 3
>Carlos: 7
>    Chen: 2
> Ben:
>Amy: 10
>Jill: 5
>Carlos: 8
>Chen: 3
> Jill:
>… and so on
>
> Then you be able to pull through that graph and find the smallest number
> of stays for each kid.
>
> Not simple, but I hope this helps.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Algorithm Help

2013-10-02 Thread Stuart Dallas
On 1 Oct 2013, at 19:51, Floyd Resler  wrote:

> Here's my task: A group of kids is going to be staying with different host 
> families throughout the next 8 months.  The number of kids staying with a 
> host family can range from 2 to 10.  When deciding which kids should stay 
> together at a host family, the idea is for the system to put together kids 
> who have stayed with each other the least on past weekends.  So, if a host 
> family can keep 5 kids, then the group of 5 kids who have stayed together the 
> least will be chosen.
> 
> I can't think of an easy, quick way to accomplish this.  I've tried various 
> approaches that have resulted in a lot of coding and being very slow.  My 
> idea was to give each group of kids a score and the lowest score is the group 
> that is selected.  However, this approach wound of iterating through several 
> arrays several times which was really slow.  Does anyone have any ideas on 
> this puzzle?

Sounds like a job for a directed graph data structure. I wish I had time to 
knock up a solution but I don't right now. This article should help you get 
started: 
http://www.codediesel.com/algorithms/building-a-graph-data-structure-in-php/

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Algorithm Help

2013-10-02 Thread Tamara Temple

On Oct 1, 2013, at 1:51 PM, Floyd Resler  wrote:

> Here's my task: A group of kids is going to be staying with different host 
> families throughout the next 8 months.  The number of kids staying with a 
> host family can range from 2 to 10.  When deciding which kids should stay 
> together at a host family, the idea is for the system to put together kids 
> who have stayed with each other the least on past weekends.  So, if a host 
> family can keep 5 kids, then the group of 5 kids who have stayed together the 
> least will be chosen.
> 
> I can't think of an easy, quick way to accomplish this.  I've tried various 
> approaches that have resulted in a lot of coding and being very slow.  My 
> idea was to give each group of kids a score and the lowest score is the group 
> that is selected.  However, this approach wound of iterating through several 
> arrays several times which was really slow.  Does anyone have any ideas on 
> this puzzle?
> 
> Thanks!
> Floyd
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

While definitely a tempting coding exercise, I just want to say that if this is 
urgent in any way, shuffling cards with the kids' names on them by hand might 
just be faster and less frustrating :)

OTOH, if this is something you're going to have to figure out week after week, 
then a software solution might be handy.

This is also not an *easy* problem to solve; there isn't a simple approach to 
optimizing this sort of thing because you're building a net between all the 
various kids based on past stays, in addition to the constraints of host family 
 capacity. Thus your previous code attempts might in fact be the end result.

Obviously, structuring the data is the key here.

I'm thinking of 3 primary models: Kids, Hosts, and Stays.

Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to 
have joining tables with Kids and Hosts.

A Stay will have one Host, and have many Kids and a date.

The algorithm then needs to make the graph where it can pull out the number of 
times any particular kid has stayed with another, looking something like this:

Amy:
   Ben: 10
   Jill: 3
   Carlos: 7
   Chen: 2
Ben:
   Amy: 10
   Jill: 5
   Carlos: 8
   Chen: 3
Jill:
   … and so on

Then you be able to pull through that graph and find the smallest number of 
stays for each kid.

Not simple, but I hope this helps.



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



Re: [PHP] Algorithm Help

2013-10-01 Thread Serge Fonville
Assuming you don't have to be exact, somthing similar to this might work.

Assign each kid to a host family randomly
for each kid, check how frequently it has been combined with the kids in
its assigned family.
if it is too close, swap with a different family
when all kids in that family are processed, move on to the next family and
repeat, excluding the first family for swapping. do the same for all
families excluding the previous families. when you have completed all
families, do another iteration or two of the whole process.

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl


2013/10/1 Floyd Resler 

> m
>
> 1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215
>
> On Oct 1, 2013, at 3:14 PM, Ashley Sheridan 
> wrote:
>
> > On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote:
> >
> >> DB or flatfile?
> >>
> >> I would create a matrix of all kids crossed with every kid. Everytime a
> kid
> >> is put in a home with another kid, ++ that index. When dispatching kids,
> >> sort by index ASC.
> >>
> >> Aziz
> >>
> >>
> >> On Tue, Oct 1, 2013 at 3:01 PM, John Meyer <
> johnme...@pueblocomputing.com>wrote:
> >>
> >>> On 10/1/2013 12:51 PM, Floyd Resler wrote:
> >>>
> >>>> Here's my task: A group of kids is going to be staying with different
> >>>> host families throughout the next 8 months.  The number of kids
> staying
> >>>> with a host family can range from 2 to 10.  When deciding which kids
> should
> >>>> stay together at a host family, the idea is for the system to put
> together
> >>>> kids who have stayed with each other the least on past weekends.  So,
> if a
> >>>> host family can keep 5 kids, then the group of 5 kids who have stayed
> >>>> together the least will be chosen.
> >>>>
> >>>> I can't think of an easy, quick way to accomplish this.  I've tried
> >>>> various approaches that have resulted in a lot of coding and being
> very
> >>>> slow.  My idea was to give each group of kids a score and the lowest
> score
> >>>> is the group that is selected.  However, this approach wound of
> iterating
> >>>> through several arrays several times which was really slow.  Does
> anyone
> >>>> have any ideas on this puzzle?
> >>>>
> >>>> Thanks!
> >>>> Floyd
> >>>>
> >>>>
> >>>> Whatever solution you're going with will probably involve a relational
> >>> database of some sort.
> >>>
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >
> >
> > This sounds remarkably like homework, which we can't help you with
> > unless you've got a specific problem that you're stuck with.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
>
> Oh, no, this is definitely not homework! :)  Although it certainly seems
> like a homework question.  This is a real world problem.  I'm keeping track
> of which kids stay with which host families in the database.  My initial
> approach was to start with kid 1 and see how many times the other kids have
> stayed with kid 1.  The move on to kid 2, and so it.  This gives me a score
> for pairs of kids.  However, if say three kids are staying at a host
> family, what is the best way to determine which set of three kids have
> stayed together the least?
>
> Thanks!
> Floyd
>
>


Re: [PHP] Algorithm Help

2013-10-01 Thread Floyd Resler
m

1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215

On Oct 1, 2013, at 3:14 PM, Ashley Sheridan  wrote:

> On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote:
> 
>> DB or flatfile?
>> 
>> I would create a matrix of all kids crossed with every kid. Everytime a kid
>> is put in a home with another kid, ++ that index. When dispatching kids,
>> sort by index ASC.
>> 
>> Aziz
>> 
>> 
>> On Tue, Oct 1, 2013 at 3:01 PM, John Meyer 
>> wrote:
>> 
>>> On 10/1/2013 12:51 PM, Floyd Resler wrote:
>>> 
>>>> Here's my task: A group of kids is going to be staying with different
>>>> host families throughout the next 8 months.  The number of kids staying
>>>> with a host family can range from 2 to 10.  When deciding which kids should
>>>> stay together at a host family, the idea is for the system to put together
>>>> kids who have stayed with each other the least on past weekends.  So, if a
>>>> host family can keep 5 kids, then the group of 5 kids who have stayed
>>>> together the least will be chosen.
>>>> 
>>>> I can't think of an easy, quick way to accomplish this.  I've tried
>>>> various approaches that have resulted in a lot of coding and being very
>>>> slow.  My idea was to give each group of kids a score and the lowest score
>>>> is the group that is selected.  However, this approach wound of iterating
>>>> through several arrays several times which was really slow.  Does anyone
>>>> have any ideas on this puzzle?
>>>> 
>>>> Thanks!
>>>> Floyd
>>>> 
>>>> 
>>>> Whatever solution you're going with will probably involve a relational
>>> database of some sort.
>>> 
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> 
>>> 
> 
> 
> This sounds remarkably like homework, which we can't help you with
> unless you've got a specific problem that you're stuck with.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 

Oh, no, this is definitely not homework! :)  Although it certainly seems like a 
homework question.  This is a real world problem.  I'm keeping track of which 
kids stay with which host families in the database.  My initial approach was to 
start with kid 1 and see how many times the other kids have stayed with kid 1.  
The move on to kid 2, and so it.  This gives me a score for pairs of kids.  
However, if say three kids are staying at a host family, what is the best way 
to determine which set of three kids have stayed together the least?

Thanks!
Floyd



Re: [PHP] Algorithm Help

2013-10-01 Thread Ashley Sheridan
On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote:

> DB or flatfile?
> 
> I would create a matrix of all kids crossed with every kid. Everytime a kid
> is put in a home with another kid, ++ that index. When dispatching kids,
> sort by index ASC.
> 
> Aziz
> 
> 
> On Tue, Oct 1, 2013 at 3:01 PM, John Meyer 
> wrote:
> 
> > On 10/1/2013 12:51 PM, Floyd Resler wrote:
> >
> >> Here's my task: A group of kids is going to be staying with different
> >> host families throughout the next 8 months.  The number of kids staying
> >> with a host family can range from 2 to 10.  When deciding which kids should
> >> stay together at a host family, the idea is for the system to put together
> >> kids who have stayed with each other the least on past weekends.  So, if a
> >> host family can keep 5 kids, then the group of 5 kids who have stayed
> >> together the least will be chosen.
> >>
> >> I can't think of an easy, quick way to accomplish this.  I've tried
> >> various approaches that have resulted in a lot of coding and being very
> >> slow.  My idea was to give each group of kids a score and the lowest score
> >> is the group that is selected.  However, this approach wound of iterating
> >> through several arrays several times which was really slow.  Does anyone
> >> have any ideas on this puzzle?
> >>
> >> Thanks!
> >> Floyd
> >>
> >>
> >>  Whatever solution you're going with will probably involve a relational
> > database of some sort.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


This sounds remarkably like homework, which we can't help you with
unless you've got a specific problem that you're stuck with.

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




Re: [PHP] Algorithm Help

2013-10-01 Thread Aziz Saleh
DB or flatfile?

I would create a matrix of all kids crossed with every kid. Everytime a kid
is put in a home with another kid, ++ that index. When dispatching kids,
sort by index ASC.

Aziz


On Tue, Oct 1, 2013 at 3:01 PM, John Meyer wrote:

> On 10/1/2013 12:51 PM, Floyd Resler wrote:
>
>> Here's my task: A group of kids is going to be staying with different
>> host families throughout the next 8 months.  The number of kids staying
>> with a host family can range from 2 to 10.  When deciding which kids should
>> stay together at a host family, the idea is for the system to put together
>> kids who have stayed with each other the least on past weekends.  So, if a
>> host family can keep 5 kids, then the group of 5 kids who have stayed
>> together the least will be chosen.
>>
>> I can't think of an easy, quick way to accomplish this.  I've tried
>> various approaches that have resulted in a lot of coding and being very
>> slow.  My idea was to give each group of kids a score and the lowest score
>> is the group that is selected.  However, this approach wound of iterating
>> through several arrays several times which was really slow.  Does anyone
>> have any ideas on this puzzle?
>>
>> Thanks!
>> Floyd
>>
>>
>>  Whatever solution you're going with will probably involve a relational
> database of some sort.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Algorithm Help

2013-10-01 Thread John Meyer

On 10/1/2013 12:51 PM, Floyd Resler wrote:

Here's my task: A group of kids is going to be staying with different host 
families throughout the next 8 months.  The number of kids staying with a host 
family can range from 2 to 10.  When deciding which kids should stay together 
at a host family, the idea is for the system to put together kids who have 
stayed with each other the least on past weekends.  So, if a host family can 
keep 5 kids, then the group of 5 kids who have stayed together the least will 
be chosen.

I can't think of an easy, quick way to accomplish this.  I've tried various 
approaches that have resulted in a lot of coding and being very slow.  My idea 
was to give each group of kids a score and the lowest score is the group that 
is selected.  However, this approach wound of iterating through several arrays 
several times which was really slow.  Does anyone have any ideas on this puzzle?

Thanks!
Floyd


Whatever solution you're going with will probably involve a relational 
database of some sort.


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



Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-10-01 Thread Aziz Saleh
Hey Tim,

It seems that deleteObject takes in 2 params, and you are sending it 1
param. I would recommend you look at the documentation and make sure you
are sending the right params.

Aziz


On Sun, Sep 29, 2013 at 10:29 PM, Tim Dunphy  wrote:

> Hi Aziz,
>
>  Thank you for getting back to me!
>
>  I appreciate you spotting that error.
>
> So I corrected that
>
>require_once 'sdk.class.php';
> if (isset($_POST['submit'])) {
>
> *  $bucket_name = $_POST['bucket_name'];*
>
>  // Create the S3 Object from the SDK
>   $s3 = new AmazonS3();
> *
>   $result = $s3->deleteObject(array(
> 'Bucket' => $bucket_name ));*
>
>
>  // The response comes back as a Simple XML Object
> // In this case we just want to know if everything was okay.
> // If not, report the message from the XML response.
>  if ((int) $response->isOK()) {
> echo 'Deleted Bucket';
> echo '';
> echo 'List Buckets';
>   } else {
> echo (string) $response->body->Message;
>   }
>  //echo '';
> }
> ?>
> 
>   Delete S3 Bucket
>
> Bucket Name:
>* 
> *
> 
>   
> 

[PHP] Algorithm Help

2013-10-01 Thread Floyd Resler
Here's my task: A group of kids is going to be staying with different host 
families throughout the next 8 months.  The number of kids staying with a host 
family can range from 2 to 10.  When deciding which kids should stay together 
at a host family, the idea is for the system to put together kids who have 
stayed with each other the least on past weekends.  So, if a host family can 
keep 5 kids, then the group of 5 kids who have stayed together the least will 
be chosen.

I can't think of an easy, quick way to accomplish this.  I've tried various 
approaches that have resulted in a lot of coding and being very slow.  My idea 
was to give each group of kids a score and the lowest score is the group that 
is selected.  However, this approach wound of iterating through several arrays 
several times which was really slow.  Does anyone have any ideas on this puzzle?

Thanks!
Floyd


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



[PHP] SOAP: Is correct to override XML standards?

2013-09-30 Thread buzon

I am working with some WSDL call for a provider.

The strange thing is that the SOAP used (for me, as client) should  
include an 'xml' element, and it is supported by the Php constructor,  
even that is not correct under XML syntaxis.


Why? Is somekind of not validation?

This works:

 $xml_content, "login" => $login );
$response = $client->__soapCall("wsdl_method", array($params));
?>

But W3 standards:

All SOAP messages are encoded using XML (see [W3C Recommendation "The  
XML Specification"] for more information on XML).
Source: http://www.w3.org/TR/2000/NOTE-SOAP-2508/#_Toc478383492  
(Relation with SOAP)


Names beginning with the string "xml", or with any string which would  
match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for  
standardization in this or future versions of this specification.
Source: http://www.w3.org/TR/REC-xml/#sec-common-syn (Common Syntactic  
Constructs)




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



Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Tim Dunphy
Hi Aziz,

 Thank you for getting back to me!

 I appreciate you spotting that error.

So I corrected that

deleteObject(array(
'Bucket' => $bucket_name ));*


 // The response comes back as a Simple XML Object
// In this case we just want to know if everything was okay.
// If not, report the message from the XML response.
 if ((int) $response->isOK()) {
echo 'Deleted Bucket';
echo '';
echo 'List Buckets';
  } else {
echo (string) $response->body->Message;
  }
 //echo '';
}
?>

  Delete S3 Bucket
   
Bucket Name:
   * *

  

Re: [PHP] Re: Sending PHP mail with Authentication

2013-09-29 Thread Paul M Foster
On Fri, Sep 27, 2013 at 12:06:30AM +0200, Maciek Sokolewicz wrote:

[snip]
 
> I'm sure I'm going to annoy people with this, but I would advise to
> never use PEAR. It's the biggest load of extremely badly coded PHP
> you'll ever find. Creating an SMTP client (with the purpose of just
> sending mail) is very easy to do yourself (and also a good challenge
> if you're not yet very skilled with PHP). Alternatively, you can
> indeed use a package such as PHPMailer; it's not perfect, and quite
> bloated for what you want probably, but it works rather well.
> 

I have to agree on the code bloat. Unless your requirements are
extraordinary (which the OP's are), the native PHP mail() function is
generally quite adequate.

Never thought about creating a PHP email client. Interesting idea...

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Aziz Saleh
No Problem, the issue is that you referring to the invalid post element
$bucket_name as opposed to the correct on bucket_name.

*$bucket_name = $_POST['$bucket_name'];*

Should be

*$bucket_name = $_POST['bucket_name'];*

Aziz


On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy  wrote:

> Hey guys,
>
>  Sorry about that i should have posted the full code to give you some idea
> of context. Anyway, here it is:
>
>require_once 'sdk.class.php';
> if (isset($_POST['submit'])) {
>
> *  $bucket_name = $_POST['$bucket_name'];*
>  // Create the S3 Object from the SDK
>   *$s3 = new AmazonS3();*
>
> *  $result = $s3->deleteObject(array(*
> *'Bucket' => $bucket_name ));*
>
>
>  // The response comes back as a Simple XML Object
> // In this case we just want to know if everything was okay.
> // If not, report the message from the XML response.
>  if ((int) $response->isOK()) {
> echo 'Deleted Bucket';
> echo '';
> echo 'List Buckets';
>   } else {
> echo (string) $response->body->Message;
>   }
>  //echo '';
> }
> ?>
> 
>   Delete S3 Bucket
>
> Bucket Name:
>   *  
> *
> 
>   
>
> So, as you can see I am taking the 'bucket_value' from $_POST and passing
> it into the call to S3.
>
> When the form comes up on the web I give it the name of one of my S3
> buckets. The result is the following error:
>
> Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php
> on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in
> /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
> variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
> Warning: preg_match() expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
> expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
> exception 'S3_Exception' with message 'S3 does not support "Array" as a
> valid bucket name. Review "Bucket Restrictions and Limitations" in the S3
> Developer Guide for more information.' in
> /var/www/awssdk/services/s3.class.php:548 Stack trace: #0
> /var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array,
> Array) #1 [internal function]: AmazonS3->delete_object(Array) #2
> /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
> /var/www/awssdk/delete_bucket.php(72): CFRuntime->__call('deleteObject',
> Array) #4 /var/www/awssdk/delete_bucket.php(72):
> AmazonS3->deleteObject(Array) #5 {main} thrown in
> /var/www/awssdk/services/s3.class.php on line 548
>
>
>
> I hope that clarifies my situation a bit. Sorry for not providing that
> sooner!
>
> Thanks
> Tim
>
>
> On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh  wrote:
>
>> Hi Tim,
>>
>> Is the call working? Does it actually get deleted?
>>
>> This could just be an issue (which I see alot) where developers do not
>> check for variables or preset them before usage, causing those notices to
>> come up (pretty harmless most of the times).
>>
>> Aziz
>>
>>
>> On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy wrote:
>>
>>> Hi All,
>>>
>>>  I am attempting to delete an empty S3 bucket using the AWS PHP SDK.
>>>
>>>  Here's how they describe the process in the docs:
>>>
>>> $result = $client->deleteBucket(array(
>>> // Bucket is required
>>> 'Bucket' => 'string',
>>> ));
>>>
>>>  You can find the full entry here:
>>>
>>> AWS PHP SDK Delete Bucket
>>> Docs<
>>> http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket
>>> >
>>>
>>>
>>> Here's how I approached it in my code:
>>>
>>>  $s3 = new AmazonS3();
>>>
>>>   $result = $s3->deleteObject(array(
>>> 'Bucket' => $bucket_name ));
>>>
>>> But when I run it, this is the error I get:
>>>
>>> 'Notice: Undefined index: $bucket_name in
>>> /var/www/awssdk/delete_bucket.php
>>> on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in
>>> /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
>>> variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
>>> Warning: preg_

Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Tim Dunphy
Hey guys,

 Sorry about that i should have posted the full code to give you some idea
of context. Anyway, here it is:

deleteObject(array(*
*'Bucket' => $bucket_name ));*


 // The response comes back as a Simple XML Object
// In this case we just want to know if everything was okay.
// If not, report the message from the XML response.
 if ((int) $response->isOK()) {
echo 'Deleted Bucket';
echo '';
echo 'List Buckets';
  } else {
echo (string) $response->body->Message;
  }
 //echo '';
}
?>

  Delete S3 Bucket
   
Bucket Name:
  *  *

  

So, as you can see I am taking the 'bucket_value' from $_POST and passing
it into the call to S3.

When the form comes up on the web I give it the name of one of my S3
buckets. The result is the following error:

Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php
on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in
/var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
Warning: preg_match() expects parameter 2 to be string, array given in
/var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
expects parameter 2 to be string, array given in
/var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
exception 'S3_Exception' with message 'S3 does not support "Array" as a
valid bucket name. Review "Bucket Restrictions and Limitations" in the S3
Developer Guide for more information.' in
/var/www/awssdk/services/s3.class.php:548 Stack trace: #0
/var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array,
Array) #1 [internal function]: AmazonS3->delete_object(Array) #2
/var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
/var/www/awssdk/delete_bucket.php(72): CFRuntime->__call('deleteObject',
Array) #4 /var/www/awssdk/delete_bucket.php(72):
AmazonS3->deleteObject(Array) #5 {main} thrown in
/var/www/awssdk/services/s3.class.php on line 548



I hope that clarifies my situation a bit. Sorry for not providing that
sooner!

Thanks
Tim


On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh  wrote:

> Hi Tim,
>
> Is the call working? Does it actually get deleted?
>
> This could just be an issue (which I see alot) where developers do not
> check for variables or preset them before usage, causing those notices to
> come up (pretty harmless most of the times).
>
> Aziz
>
>
> On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy  wrote:
>
>> Hi All,
>>
>>  I am attempting to delete an empty S3 bucket using the AWS PHP SDK.
>>
>>  Here's how they describe the process in the docs:
>>
>> $result = $client->deleteBucket(array(
>> // Bucket is required
>> 'Bucket' => 'string',
>> ));
>>
>>  You can find the full entry here:
>>
>> AWS PHP SDK Delete Bucket
>> Docs<
>> http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket
>> >
>>
>>
>> Here's how I approached it in my code:
>>
>>  $s3 = new AmazonS3();
>>
>>   $result = $s3->deleteObject(array(
>> 'Bucket' => $bucket_name ));
>>
>> But when I run it, this is the error I get:
>>
>> 'Notice: Undefined index: $bucket_name in
>> /var/www/awssdk/delete_bucket.php
>> on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in
>> /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
>> variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
>> Warning: preg_match() expects parameter 2 to be string, array given in
>> /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
>> expects parameter 2 to be string, array given in
>> /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
>> exception 'S3_Exception' with message 'S3 does not support "Array" as a
>> valid bucket name. Review "Bucket Restrictions and Limitations" in the S3
>> Developer Guide for more information.' in
>> /var/www/awssdk/services/s3.class.php:548 Stack trace: #0
>> /var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array,
>> Array) #1 [internal function]: AmazonS3->delete_object(Array) #2
>> /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
>> /var/www/awssdk/delete_bucket.php(10): CFRuntime->__call('deleteObject',
>> Array) #4 /var/www/awssdk/delete_bucket.php(10):
>> AmazonS3->deleteObject(Array) #5 {main} thrown in
>> /var/www/awssd

Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Aziz Saleh
Hi Tim,

Is the call working? Does it actually get deleted?

This could just be an issue (which I see alot) where developers do not
check for variables or preset them before usage, causing those notices to
come up (pretty harmless most of the times).

Aziz


On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy  wrote:

> Hi All,
>
>  I am attempting to delete an empty S3 bucket using the AWS PHP SDK.
>
>  Here's how they describe the process in the docs:
>
> $result = $client->deleteBucket(array(
> // Bucket is required
> 'Bucket' => 'string',
> ));
>
>  You can find the full entry here:
>
> AWS PHP SDK Delete Bucket
> Docs<
> http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket
> >
>
> Here's how I approached it in my code:
>
>  $s3 = new AmazonS3();
>
>   $result = $s3->deleteObject(array(
> 'Bucket' => $bucket_name ));
>
> But when I run it, this is the error I get:
>
> 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php
> on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in
> /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
> variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
> Warning: preg_match() expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
> expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
> exception 'S3_Exception' with message 'S3 does not support "Array" as a
> valid bucket name. Review "Bucket Restrictions and Limitations" in the S3
> Developer Guide for more information.' in
> /var/www/awssdk/services/s3.class.php:548 Stack trace: #0
> /var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array,
> Array) #1 [internal function]: AmazonS3->delete_object(Array) #2
> /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
> /var/www/awssdk/delete_bucket.php(10): CFRuntime->__call('deleteObject',
> Array) #4 /var/www/awssdk/delete_bucket.php(10):
> AmazonS3->deleteObject(Array) #5 {main} thrown in
> /var/www/awssdk/services/s3.class.php on line 548'
>
>
> This is line 548 in the above referenced file:
>
> // Validate the S3 bucket name
> if (!$this->validate_bucketname_support($bucket))
> {
> // @codeCoverageIgnoreStart
> throw new S3_Exception('S3 does not support "' .
> $bucket . '" as a valid bucket name. Review "Bucket Restrictions and
> Limitations" in the S3 Developer Guide for more information.');
> // @codeCoverageIgnoreEnd
> }
>
>
>
>
> Has anyone played around enough with the AWS SDK to know what I'm doing
> wrong here? Would anyone else be able to hazard a guess?
>
> Thanks
> Tim
> --
> GPG me!!
>
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>


Re: [PHP] Switch Statement

2013-09-29 Thread mrfroasty
Hello,

I suggest you put default in that switch statement and var_dump the
$_POST.That should be enough for a programmer to pin point what goes wrong.

P:S
**You might want to consider versioning your codes to go back into its
history to see what has changed.

Muhsin

On 09/29/2013 04:33 AM, Ethan Rosenberg wrote:
> Dear List -
>
> I have a working program.  I made one change in a switch statement,
> and it does not work.  I'm probably missing something fundamental.
>
> Here are some code SNIPPETS...  [please note that all my debug
> statements are at the left margin]
>
> Setup...
>
>  session_start();
> session_name("STORE");
> set_time_limit(2400);
> ini_set('display_errors', 'on');
> ini_set('display_startup_errors', 'on');
> error_reporting(-2);
>
> ini_set('error_reporting', 'E_ALL | E_STRICT');
> ini_set('html_errors', 'On');
> ini_set('log_errors', 'On');
> require '/home/ethan/P/wk.inc'; //password file
> $db = "Store";
> $cxn =mysqli_connect($host,$user,$password,$db);
> if (!$cxn)
> {
> die('Connect Error (' . mysqli_connect_errno() . ') '
> . mysqli_connect_error());
> }// no error   
> if($_REQUEST['welcome_already_seen']!= "already_seen")   
> show_welcome();
> 
> //end setup
> function show_welcome() //this is the input screen
> {
> 
>
> echo "  value='already_seen'>";
> echo " ";
>
> 
> }
>
> 
> //end input screen
>
> //Switch statement
>
> echo 'before';
> print_r($_POST); //post#1   
>
> switch ( $_POST['next_step'] )
> {
>
> case 'step20':
> {
> pint_r($_POST);//post#2   
> echo 'step20';
> if(!empty($_POST['Cust_Num']))
> good();
> if(empty($_POST['Cust_Num']))
> bad();
> break;
> } //end step20
>
> 
> } //end switch
> 
> 
>
> post#1
>
> beforeArray
> (
> [Cust_Num] => 123
> [Fname] =>
> [Lname] =>
> [Street] =>
> [City] =>
> [state] => NY
> [Zip] => 10952
> [PH1] =>
>     [PH2] =>
> [PH3] =>
> [Date] =>
> [welcome_already_seen] => already_seen
> [next_step] => step20
>
> )
>
> Cust_Num state and Zip are as entered.
>
> The switch statement is never entered, since post#2 is never
> displayed, and neither good() or bad() functions are entered.   
>
>
> TIA
>
> Ethan
>
>
>


-- 
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,PHP
Typo:40WPM
url:http://www.mzalendo.net
url:http://www.zanbytes.com



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



Re: [PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Ashley Sheridan
On Sun, 2013-09-29 at 12:30 -0400, Tim Dunphy wrote:

> Hi All,
> 
>  I am attempting to delete an empty S3 bucket using the AWS PHP SDK.
> 
>  Here's how they describe the process in the docs:
> 
> $result = $client->deleteBucket(array(
> // Bucket is required
> 'Bucket' => 'string',
> ));
> 
>  You can find the full entry here:
> 
> AWS PHP SDK Delete Bucket
> Docs<http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket>
> 
> Here's how I approached it in my code:
> 
>  $s3 = new AmazonS3();
> 
>   $result = $s3->deleteObject(array(
> 'Bucket' => $bucket_name ));
> 
> But when I run it, this is the error I get:
> 
> 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php
> on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in
> /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
> variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
> Warning: preg_match() expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
> expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
> exception 'S3_Exception' with message 'S3 does not support "Array" as a
> valid bucket name. Review "Bucket Restrictions and Limitations" in the S3
> Developer Guide for more information.' in
> /var/www/awssdk/services/s3.class.php:548 Stack trace: #0
> /var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array,
> Array) #1 [internal function]: AmazonS3->delete_object(Array) #2
> /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
> /var/www/awssdk/delete_bucket.php(10): CFRuntime->__call('deleteObject',
> Array) #4 /var/www/awssdk/delete_bucket.php(10):
> AmazonS3->deleteObject(Array) #5 {main} thrown in
> /var/www/awssdk/services/s3.class.php on line 548'
> 
> 
> This is line 548 in the above referenced file:
> 
> // Validate the S3 bucket name
> if (!$this->validate_bucketname_support($bucket))
> {
> // @codeCoverageIgnoreStart
> throw new S3_Exception('S3 does not support "' .
> $bucket . '" as a valid bucket name. Review "Bucket Restrictions and
> Limitations" in the S3 Developer Guide for more information.');
> // @codeCoverageIgnoreEnd
> }
> 
> 
> 
> 
> Has anyone played around enough with the AWS SDK to know what I'm doing
> wrong here? Would anyone else be able to hazard a guess?
> 
> Thanks
> Tim


Your code is failing because $bucket_name, I suspect, is null. Where do
you define this variable before you use it in this bit of code:

$result = $s3->deleteObject(array(
'Bucket' => $bucket_name ));

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




[PHP] delete S3 bucket with AWS PHP SDK

2013-09-29 Thread Tim Dunphy
Hi All,

 I am attempting to delete an empty S3 bucket using the AWS PHP SDK.

 Here's how they describe the process in the docs:

$result = $client->deleteBucket(array(
// Bucket is required
'Bucket' => 'string',
));

 You can find the full entry here:

AWS PHP SDK Delete Bucket
Docs<http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket>

Here's how I approached it in my code:

 $s3 = new AmazonS3();

  $result = $s3->deleteObject(array(
'Bucket' => $bucket_name ));

But when I run it, this is the error I get:

'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php
on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in
/var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
Warning: preg_match() expects parameter 2 to be string, array given in
/var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
expects parameter 2 to be string, array given in
/var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
exception 'S3_Exception' with message 'S3 does not support "Array" as a
valid bucket name. Review "Bucket Restrictions and Limitations" in the S3
Developer Guide for more information.' in
/var/www/awssdk/services/s3.class.php:548 Stack trace: #0
/var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array,
Array) #1 [internal function]: AmazonS3->delete_object(Array) #2
/var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
/var/www/awssdk/delete_bucket.php(10): CFRuntime->__call('deleteObject',
Array) #4 /var/www/awssdk/delete_bucket.php(10):
AmazonS3->deleteObject(Array) #5 {main} thrown in
/var/www/awssdk/services/s3.class.php on line 548'


This is line 548 in the above referenced file:

// Validate the S3 bucket name
if (!$this->validate_bucketname_support($bucket))
{
// @codeCoverageIgnoreStart
throw new S3_Exception('S3 does not support "' .
$bucket . '" as a valid bucket name. Review "Bucket Restrictions and
Limitations" in the S3 Developer Guide for more information.');
// @codeCoverageIgnoreEnd
}




Has anyone played around enough with the AWS SDK to know what I'm doing
wrong here? Would anyone else be able to hazard a guess?

Thanks
Tim
-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B


Re: [PHP] Switch Statement

2013-09-29 Thread Aziz Saleh
What is the output?


On Sun, Sep 29, 2013 at 1:34 AM, Ethan Rosenberg <
erosenb...@hygeiabiomedical.com> wrote:

> On 09/28/2013 10:53 PM, Aziz Saleh wrote:
>
>> Ethan, can you do a var_dump instead of print_r. It might be that
>> next_step
>> has spaces in it causing the switch to not match.
>>
>> Aziz
>>
>>
>>  
>
> Aziz -
>
> Used var_dump no further information
>
>
> Ethan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Running a command without shell

2013-09-29 Thread vitalif

Hi!

Is it possible to run a command and capture its output via an FD (like 
in proc_open()), but without using the shell? As far as I can see now 
there is no way to do it. I think that's a simple feature, maybe just 
add it to proc_open()? (for example run command directly using exec() if 
the first argument is an array?) it would be rational because there is 
already such option for Windows...


--
With best regards,
  Vitaliy Filippov

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



Re: [PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner

On 9/29/2013 1:38 AM, Jim Giner wrote:

   session_start();
 session_name("STORE");
 set_time_limit(2400);
 ini_set('display_errors', 'on');
 ini_set('display_startup_errors', 'on');
 error_reporting(-2);

 ini_set('error_reporting', 'E_ALL | E_STRICT');
 ini_set('html_errors', 'On');
 ini_set('log_errors', 'On');

This is what you should have in place of all of the above:

session_start();
error_reporting(E_ALL | E_STRICT | E_NOTICE);	ini_set('display_errors', 
'1');

set_time_limit(2);// if you use more than 2 secs you have a problem




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



Re: [PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner

On 9/29/2013 1:29 AM, Ethan Rosenberg wrote:

On 09/28/2013 11:59 PM, Jim Giner wrote:



Ethan,Ethan,Ethan - what is all this "stuff" you have at the top???  Do
you know how any of this is supposed to be written?  You can not put
Constants in quotes - they become just plain strings then, not Constants
with the predefined values you (and the functions) are expecting.  For
example, 'on' is NOT the same as the use of the word :  on.  And your
error_reporting setting (which you are attempting to do TWICE) is
actually causing your script to NOT show any errors, which is preventing
you from seeing that your script dies at the misspelled print statement
and never gets to the pair of if statements that should call your good
and bad functions.

Hate to do this to you, but you've been attempting to pick up PHP for
two years now almost and from this latest post you appear to not have
learned anything.

And WHY would you EVER want to have a time limit of 2400 seconds???

And stop burying functions in the middle of your straight line code.
It's ridiculous and makes reading your scripts a royal PIA.


Jim -

Thanks.

Changed error_reporting to -1. No error messages. No change in output.

Ethan

CORRECT ALL THE WRONG SHIT AND YOU"LL GET ERROR MESSAGES!!!

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



Re: [PHP] Switch Statement

2013-09-28 Thread Ethan Rosenberg

On 09/28/2013 10:53 PM, Aziz Saleh wrote:

Ethan, can you do a var_dump instead of print_r. It might be that next_step
has spaces in it causing the switch to not match.

Aziz





Aziz -

Used var_dump no further information

Ethan


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



Re: [PHP] Re: Switch Statement

2013-09-28 Thread Ethan Rosenberg

On 09/28/2013 11:59 PM, Jim Giner wrote:



Ethan,Ethan,Ethan - what is all this "stuff" you have at the top???  Do
you know how any of this is supposed to be written?  You can not put
Constants in quotes - they become just plain strings then, not Constants
with the predefined values you (and the functions) are expecting.  For
example, 'on' is NOT the same as the use of the word :  on.  And your
error_reporting setting (which you are attempting to do TWICE) is
actually causing your script to NOT show any errors, which is preventing
you from seeing that your script dies at the misspelled print statement
and never gets to the pair of if statements that should call your good
and bad functions.

Hate to do this to you, but you've been attempting to pick up PHP for
two years now almost and from this latest post you appear to not have
learned anything.

And WHY would you EVER want to have a time limit of 2400 seconds???

And stop burying functions in the middle of your straight line code.
It's ridiculous and makes reading your scripts a royal PIA.


Jim -

Thanks.

Changed error_reporting to -1. No error messages. No change in output.

Ethan

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



Re: [PHP] create a local temp table in local machine

2013-09-28 Thread iccsi

Thanks for the message,
Do you have any information how to create JS file and how to access from 
jQuery auto complete?

Thanks again for helping,

Regards,

Iccsi,



"Bastien"  wrote in message 
news:57469e24-56e6-40c9-8176-64cd8444f...@gmail.com...




Thanks,

Bastien


On Sep 28, 2013, at 8:24 PM, "iccsi"  wrote:

Thanks for the information and help,
Yes, my data is pretty much static,
Can you please give me some link for the solution?
It is the solution I am looking for my current situation,

Thanks a million for helping,

Regards,

Iccsi,


I don't have a link unfortunately. The system I did it for is proprietary. 
But I do recall it was a pretty switch in the JS to view the list from the 
static file. The JS file with the static data was just an array and the 
autocomplete looked at that as the data source


Sorry

Bastien 



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



[PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner



Ethan,Ethan,Ethan - what is all this "stuff" you have at the top???  Do 
you know how any of this is supposed to be written?  You can not put 
Constants in quotes - they become just plain strings then, not Constants 
with the predefined values you (and the functions) are expecting.  For 
example, 'on' is NOT the same as the use of the word :  on.  And your 
error_reporting setting (which you are attempting to do TWICE) is 
actually causing your script to NOT show any errors, which is preventing 
you from seeing that your script dies at the misspelled print statement 
and never gets to the pair of if statements that should call your good 
and bad functions.


Hate to do this to you, but you've been attempting to pick up PHP for 
two years now almost and from this latest post you appear to not have 
learned anything.


And WHY would you EVER want to have a time limit of 2400 seconds???

And stop burying functions in the middle of your straight line code. 
It's ridiculous and makes reading your scripts a royal PIA.




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



[PHP] Re: Switch Statement

2013-09-28 Thread Jim Giner

On 9/28/2013 10:33 PM, Ethan Rosenberg wrote:

Dear List -

I have a working program.  I made one change in a switch statement, and
it does not work.  I'm probably missing something fundamental.

Here are some code SNIPPETS...  [please note that all my debug
statements are at the left margin]

Setup...



 echo " ";
 echo " ";

 
 }


 //end input screen

 //Switch statement

echo 'before';
print_r($_POST); //post#1

 switch ( $_POST['next_step'] )
 {

 case 'step20':
 {
pint_r($_POST);//post#2
echo 'step20';
 if(!empty($_POST['Cust_Num']))
 good();
 if(empty($_POST['Cust_Num']))
 bad();
 break;
 } //end step20

 
 } //end switch



post#1

beforeArray
(
 [Cust_Num] => 123
 [Fname] =>
 [Lname] =>
 [Street] =>
 [City] =>
 [state] => NY
 [Zip] => 10952
 [PH1] =>
 [PH2] =>
 [PH3] =>
 [Date] =>
 [welcome_already_seen] => already_seen
 [next_step] => step20

)

Cust_Num state and Zip are as entered.

The switch statement is never entered, since post#2 is never displayed,
and neither good() or bad() functions are entered.


TIA

Ethan


Once again you are posting code that has no chance of running.  And 
since you are DISABLING error reporting with that "-2" value you won't 
even know you have bad code.


Try again.  Post#2 will never display since you aren't printing it.

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



Re: [PHP] create a local temp table in local machine

2013-09-28 Thread Bastien


Thanks,

Bastien

> On Sep 28, 2013, at 8:24 PM, "iccsi"  wrote:
> 
> Thanks for the information and help,
> Yes, my data is pretty much static,
> Can you please give me some link for the solution?
> It is the solution I am looking for my current situation,
> 
> Thanks a million for helping,
> 
> Regards,
> 
> Iccsi,

I don't have a link unfortunately. The system I did it for is proprietary. But 
I do recall it was a pretty switch in the JS to view the list from the static 
file. The JS file with the static data was just an array and the autocomplete 
looked at that as the data source

Sorry

Bastien

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



Re: [PHP] Switch Statement

2013-09-28 Thread Aziz Saleh
Ethan, can you do a var_dump instead of print_r. It might be that next_step
has spaces in it causing the switch to not match.

Aziz


On Sat, Sep 28, 2013 at 10:33 PM, Ethan Rosenberg <
erosenb...@hygeiabiomedical.com> wrote:

> Dear List -
>
> I have a working program.  I made one change in a switch statement, and it
> does not work.  I'm probably missing something fundamental.
>
> Here are some code SNIPPETS...  [please note that all my debug statements
> are at the left margin]
>
> Setup...
>
>  session_start();
> session_name("STORE");
> set_time_limit(2400);
> ini_set('display_errors', 'on');
> ini_set('display_startup_**errors', 'on');
> error_reporting(-2);
>
> ini_set('error_reporting', 'E_ALL | E_STRICT');
> ini_set('html_errors', 'On');
> ini_set('log_errors', 'On');
> require '/home/ethan/P/wk.inc'; //password file
> $db = "Store";
> $cxn =mysqli_connect($host,$user,$**password,$db);
> if (!$cxn)
> {
> die('Connect Error (' . mysqli_connect_errno() . ') '
> . mysqli_connect_error());
> }// no error
> if($_REQUEST['welcome_already_**seen']!= "already_seen")
>
> show_welcome();
>
> //end setup
> function show_welcome() //this is the input screen
> {
> 
>
> echo "  value='already_seen'>";
> echo " ";
>
> 
> }
>
>
> //end input screen
>
> //Switch statement
>
> echo 'before';
> print_r($_POST); //post#1
>
> switch ( $_POST['next_step'] )
> {
>
> case 'step20':
> {
> pint_r($_POST); //post#2
> echo 'step20';
> if(!empty($_POST['Cust_Num']))
> good();
> if(empty($_POST['Cust_Num']))
> bad();
> break;
> } //end step20
>
> 
> } //end switch
>
>
>
> post#1
>
> beforeArray
> (
> [Cust_Num] => 123
> [Fname] =>
> [Lname] =>
> [Street] =>
> [City] =>
> [state] => NY
> [Zip] => 10952
> [PH1] =>
> [PH2] =>
> [PH3] =>
> [Date] =>
> [welcome_already_seen] => already_seen
> [next_step] => step20
>
> )
>
> Cust_Num state and Zip are as entered.
>
> The switch statement is never entered, since post#2 is never displayed,
> and neither good() or bad() functions are entered.
>
>
> TIA
>
> Ethan
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Switch Statement

2013-09-28 Thread Ethan Rosenberg

Dear List -

I have a working program.  I made one change in a switch statement, and 
it does not work.  I'm probably missing something fundamental.


Here are some code SNIPPETS...  [please note that all my debug 
statements are at the left margin]


Setup...



	echo " value='already_seen'>";

echo " ";


}


//end input screen

//Switch statement

echo 'before';
print_r($_POST); //post#1   

switch ( $_POST['next_step'] )
{

case 'step20':
{
pint_r($_POST); //post#2
echo 'step20';
if(!empty($_POST['Cust_Num']))
good();
if(empty($_POST['Cust_Num']))
bad();
break;
} //end step20


} //end switch



post#1

beforeArray
(
[Cust_Num] => 123
[Fname] =>
[Lname] =>
[Street] =>
[City] =>
[state] => NY
[Zip] => 10952
[PH1] =>
[PH2] =>
[PH3] =>
[Date] =>
[welcome_already_seen] => already_seen
[next_step] => step20

)

Cust_Num state and Zip are as entered.

The switch statement is never entered, since post#2 is never displayed, 
and neither good() or bad() functions are entered.		



TIA

Ethan



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



Re: [PHP] create a local temp table in local machine

2013-09-28 Thread iccsi

Thanks for the information and help,
Yes, my data is pretty much static,
Can you please give me some link for the solution?
It is the solution I am looking for my current situation,

Thanks a million for helping,

Regards,

Iccsi,

"Bastien"  wrote in message 
news:deb5dfe9-ec7f-4bc5-9e2e-acfb85039...@gmail.com...





On Sep 28, 2013, at 6:00 PM, "iccsi"  wrote:

Thanks for the message and help,
because I use jQuery autocomplete which has performance issue for 
thousands records due to network load data.
I want to load the data to local table to resolve performance issue, if it 
possible I can load to an array in the memory.


Thanks again for helping,

Regards,

iccsi,

"Bastien"  wrote in message 
news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com...




Thanks,

Bastien


On Sep 28, 2013, at 3:24 PM, "iccsi"  wrote:

I need create a local table on the local machine.
I would like to know is it possible to down on server side or client side 
or jQuery to do the work.

Your information and help is great appreciated,

regards,


Iccsi


If you're looking to create a SQl table then most but not all browsers can 
use SQLite locally for data storage ( it does require newer browsers).


You haven't stated the goal for this so other options could include 
sending csv or json data down to the browser and using jquery, angular or 
some other JS framework to manipulate that data may also be an option




I had exactly this situation, large list with the autocomplete. I cached the 
list to a JS file and ran the autocomplete from that. It works well if the 
list is relatively static which mine was. It will be tougher if the list is 
dynamic, but you could send the data down after the initial page load.


HTH

Bastien= 



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



Re: [PHP] create a local temp table in local machine

2013-09-28 Thread Bastien


> On Sep 28, 2013, at 6:00 PM, "iccsi"  wrote:
> 
> Thanks for the message and help,
> because I use jQuery autocomplete which has performance issue for thousands 
> records due to network load data.
> I want to load the data to local table to resolve performance issue, if it 
> possible I can load to an array in the memory.
> 
> Thanks again for helping,
> 
> Regards,
> 
> iccsi,
> 
> "Bastien"  wrote in message 
> news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com...
> 
> 
> 
> Thanks,
> 
> Bastien
> 
>> On Sep 28, 2013, at 3:24 PM, "iccsi"  wrote:
>> 
>> I need create a local table on the local machine.
>> I would like to know is it possible to down on server side or client side or 
>> jQuery to do the work.
>> Your information and help is great appreciated,
>> 
>> regards,
>> 
>> 
>> Iccsi
> 
> If you're looking to create a SQl table then most but not all browsers can 
> use SQLite locally for data storage ( it does require newer browsers).
> 
> You haven't stated the goal for this so other options could include sending 
> csv or json data down to the browser and using jquery, angular or some other 
> JS framework to manipulate that data may also be an option
> 

I had exactly this situation, large list with the autocomplete. I cached the 
list to a JS file and ran the autocomplete from that. It works well if the list 
is relatively static which mine was. It will be tougher if the list is dynamic, 
but you could send the data down after the initial page load. 

HTH

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



Re: [PHP] create a local temp table in local machine

2013-09-28 Thread iccsi

Thanks for the message and help,
because I use jQuery autocomplete which has performance issue for thousands 
records due to network load data.
I want to load the data to local table to resolve performance issue, if it 
possible I can load to an array in the memory.


Thanks again for helping,

Regards,

iccsi,

"Bastien"  wrote in message 
news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com...




Thanks,

Bastien


On Sep 28, 2013, at 3:24 PM, "iccsi"  wrote:

I need create a local table on the local machine.
I would like to know is it possible to down on server side or client side 
or jQuery to do the work.

Your information and help is great appreciated,

regards,


Iccsi


If you're looking to create a SQl table then most but not all browsers can 
use SQLite locally for data storage ( it does require newer browsers).


You haven't stated the goal for this so other options could include sending 
csv or json data down to the browser and using jquery, angular or some other 
JS framework to manipulate that data may also be an option



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



Re: [PHP] create a local temp table in local machine

2013-09-28 Thread Bastien


Thanks,

Bastien

> On Sep 28, 2013, at 3:24 PM, "iccsi"  wrote:
> 
> I need create a local table on the local machine.
> I would like to know is it possible to down on server side or client side or 
> jQuery to do the work.
> Your information and help is great appreciated,
> 
> regards,
> 
> 
> Iccsi

If you're looking to create a SQl table then most but not all browsers can use 
SQLite locally for data storage ( it does require newer browsers). 

You haven't stated the goal for this so other options could include sending csv 
or json data down to the browser and using jquery, angular or some other JS 
framework to manipulate that data may also be an option



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



[PHP] create a local temp table in local machine

2013-09-28 Thread iccsi

I need create a local table on the local machine.
I would like to know is it possible to down on server side or client side or 
jQuery to do the work.

Your information and help is great appreciated,

regards,


Iccsi, 



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



Re: [PHP] How to capture uploaded file data

2013-09-28 Thread Bastien


Thanks,

Bastien

> On Sep 27, 2013, at 12:56 AM, Mariusz Drozdowski  wrote:
> 
> Hi all php experts,
> 
> I would like to ask you all a question, I hope this is the right place
> to ask it.
> 
> I'm writing a PHP extension now in c/c++. User uploads a file (could be POST
> or PUT method, but I can limit it to POST only). I need to capture the
> file data while being
> uploaded, without writing it to disk on the server. I need to process
> the data and (maybe,
> depending on a situation) send it somewhere else or save it to disk.
> Of course I know, that I can process the file
> after it has been uploaded (saved on disk on the server), but I would
> like to avoid it.
> I also need to do something opposite: I need to generate a file "on the
> fly" and send it
> to the user. All metadata of the generated file is known beforehand
> (e.g. size, name).
> 
> I've been searching around for some time now and I could not find
> anything even close to the solution.
> Is there any example(s) or existing PHP extension that do(es) something
> like this (at least something simmilar) ?
> If you could give me any pointers that would be awesome.
> 
> Thanks for your help 

The question I have is why? Should your upload fail for any reason you've got a 
half processed file that is non-recoverable.  No do-overs. If you stick to the 
standard processes with out the extension,

Upload
Save somewhere (or leave in temp upload folder)
Process
Send result back to user 
Unlink file

Generating the file and sending it to the user is also pretty standard

Create your dataset
Send appropriate headers
Send data
Close connection

For this, there usually isn't a need to save the file. You may run into issues 
streaming the data to certain browsers. 

Also one of the main downsides to your upload is high load situations or large 
file situations (where file size exceeds php's upload limit). 

My personal preference is to save that file to disk so that if needed I can 
work with it later ( if say the server load is high) and email the results to 
the user. 



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



[PHP] How to capture uploaded file data

2013-09-26 Thread Mariusz Drozdowski
Hi all php experts,

I would like to ask you all a question, I hope this is the right place
to ask it.

I'm writing a PHP extension now in c/c++. User uploads a file (could be POST
or PUT method, but I can limit it to POST only). I need to capture the
file data while being
uploaded, without writing it to disk on the server. I need to process
the data and (maybe,
depending on a situation) send it somewhere else or save it to disk.
Of course I know, that I can process the file
after it has been uploaded (saved on disk on the server), but I would
like to avoid it.
I also need to do something opposite: I need to generate a file "on the
fly" and send it
to the user. All metadata of the generated file is known beforehand
(e.g. size, name).

I've been searching around for some time now and I could not find
anything even close to the solution.
Is there any example(s) or existing PHP extension that do(es) something
like this (at least something simmilar) ?
If you could give me any pointers that would be awesome.

Thanks for your help in advance.

Mariusz


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



[PHP] Re: Sending PHP mail with Authentication

2013-09-26 Thread Maciek Sokolewicz

On 25-9-2013 22:11, dealTek wrote:

Hi All,

Semi newbie email question...

I have used the - mail() — Send mail php function to send email from a site.

now it seems the server is blocking this for safety because I should be using 
authentication

Q: mail() does not have authentication - correct?

Q: So I read from the link below that maybe I should use - PEAR Mail package 
 is this a good choice to send mail with authentication?

...any suggestions for basic sending email with authentication (setup info and 
links also) would be welcome


http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm

--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]



I'm sure I'm going to annoy people with this, but I would advise to 
never use PEAR. It's the biggest load of extremely badly coded PHP 
you'll ever find. Creating an SMTP client (with the purpose of just 
sending mail) is very easy to do yourself (and also a good challenge if 
you're not yet very skilled with PHP). Alternatively, you can indeed use 
a package such as PHPMailer; it's not perfect, and quite bloated for 
what you want probably, but it works rather well.


- Tul

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



Re: [PHP] PHP and curl

2013-09-26 Thread Shawn McKenzie
Unfortunately this isn't anything to do with PHP.  I don't have any info on
the app, what it's supposed to return or what the parameter passed should
be.  The PHP soap call is working, but the app isn't returning what you
want or expect I guess.


On Thu, Sep 26, 2013 at 8:36 AM, Alf Stockton  wrote:

>  Shawn, that was silly of me. I have now removed the echo but I still do
> not get the expected result from the server.
> var_dump of $result returns:-
>
> object(stdClass)#2 (1) {
>   ["GetSequenceNoResult"]=>
>   object(stdClass)#3 (6) {
> ["iServerNo"]=>
> int(0)
> ["iClientNo"]=>
> int(0)
> ["bNoLimitDownload"]=>
> bool(false)
> ["dtStartDate"]=>
> string(19) "0001-01-01T00:00:00"
> ["dtEndDate"]=>
> string(19) "0001-01-01T00:00:00"
> ["dtServerTime"]=>
> string(19) "0001-01-01T00:00:00"
>   }
> }
>
> whereas the expected result is to have each of those fields containing
> data.
> My code now looks like
>
>  $strTerminalname = "CIS";
> $version = "1.2";
> $client = new SoapClient(
> "http://192.168.0.10/CISWebService/Mediamanager.asmx?WSDL";<http://192.168.0.10/CISWebService/Mediamanager.asmx?WSDL>
> );
> $result = $client->GetSequenceNo($strTerminalname);
> print_r($result);
> var_dump($result);
> ?>
>
>
> On 25/09/13 17:23, Shawn McKenzie wrote:
>
> $result = $client->GetSequenceNo( "CIS" ); shouldn't be throwing that
> error.  Maybe you are trying to do something with $result afterwards?  Try
> var_dump($result);
>
>
> On Wed, Sep 25, 2013 at 10:12 AM, Alf Stockton  wrote:
>
>>
>> On 25/09/13 16:52, Shawn McKenzie wrote:
>>
>> $client->GetSequenceNo( $parameters );
>>
>> That unfortunately returns
>>
>> alf@alf-ThinkPad-T500:~/Development/PHP/DevIt$ php
>> php-soap-web-service.php > test.txt
>> PHP Catchable fatal error:  Object of class stdClass could not be
>> converted to string in
>> /home/alf/Development/PHP/DevIt/php-soap-web-service.php on line 7
>>
>> No matter if I use
>> $result = $client->GetSequenceNo( "CIS" );
>> or
>> $result = $client->GetSequenceNo($strTerminalname);
>>
>>
>>
>>
>> --
>>
>> Regards,
>> Alf Stockton  www.stockton.co.za
>>
>>
>
>
>  --
>  --
> Thanks!
> -Shawn
> --
>
>
> --
>
> Regards,
> Alf Stockton  www.stockton.co.za
>
>


-- 
Thanks!
-Shawn


Re: [PHP] Apache

2013-09-25 Thread Robert Stone





 De: Ashley Sheridan 
Para: m...@nikha.org; Domain nikha.org  
Cc: php-general@lists.php.net 
Enviadas: Quarta-feira, 25 de Setembro de 2013 2:22
Assunto: Re: [PHP] Apache
 



"Domain nikha.org"  wrote:
>Ashley Sheridan am Montag, 23. September 2013 - 21:35:
>
>> No, no, no! That is not a good stand-in for fundamental security
>> principles!
>> 
>> This is a better method for ensuring an image is really an image:
>> 
>> > if(isset($_FILES['file']))
>> {
>>     list($width, $height) = getimagesize($_FILES['file']['tmp_name']);
>>     if($width && $height)
>>     {
>>         $source = imagecreatefromjpeg($_FILES['file']['tmp_name']);
>>         $dest = imagecreatetruecolor($width, $height);
>>         
>>         imagecopyresampled($dest, $source,
>>         0, 0, 0, 0,
>>         $width, $height, $width, $height);
>>         imagejpeg($dest, basename($_FILES['file']['tmp_name']));
>>     }
>>     else
>>         echo "{$_FILES['file']['name']} is not a jpeg";
>> }
>> ?>
>> 
>>     
>>     
>> 
>> 
>> Obviously it's only rough, and checks only for jpeg images, but
>that's
>> easy to alter. I've just tested this with a regular jpeg, the same
>jpeg
>> with PHP code concatenated onto the end (which still appears to be a
>> valid image to viewing/editing software) and a pure PHP file with a
>.jpg
>> extension. In the case of the first 2, a new jpeg is generated with
>the
>> same image and without the code. The third example just echoes out an
>> error.
>> 
>
>Dear Ashley, nice, but useless for this problem!
>

The problem was to do with an image upload, so no, not useless. 

>First, because users may upload other things than images! PDF's, audio
>files, videos etc!

In an earlier email I detailed some methods for validating other types, such as 
DomDocument for HTML, XML, svg, etc, or fpdf for PDF. 

And on behalf images: GD you are using handles only
>jpeg, gif and png. There are about hunderd other image types on the
>way,

At the moment those are the 3 raster formats you can use on the web, so those 
are the ones that pose an issue. If you're using anything else, it's not for 
web and doesn't need to be in a publicly accessible location. 

>users can upload! How to detect them, if the extension is missleading?

The extension comes from the user. Never trust the user, ever.

>
>And even if we succeed: As your script demonstrates very well,
>malicious
>code does not affect the rendering of the image. 

My script does effectively strip out malicious code though, even if it can't 
easily be seen.

The hacker says: Hi,
>this is a nice picture, play it, and then, please do this--follows his
>code, that can be a desaster for the whole system.

Social engineering is a whole different issue.

>
>Yes, your script seems to purge the image file, simply because GD does
>not copy the malware code. But why are you sure about that? You cannot
>see that code, OK, but may be it was executed in the plain GD
>environement? 

GD isn't a PHP parser, and PHP doesn't execute the image before GD touches it. 
Infact, Apache isn't even involved between GD and the image at that point, so 
it won't suffer from this bad config.

What you are doing is dangerous, because you force the
>execution of things that should be never executed!

Erm, no, the image isn't being executed.

>
>"no no no" forget it. After all we cannot exclude that users come in
>with malware. 

If you think it's fine that a user be able to upload malware, then you're going 
to have a very bad time.

But we MUST exclude, it is executed on the web server.

This is important too, but in this profession belt and braces is best I 
believe. 

>That is the Apache chainsaw massacre as Steward whould say. And
>probably
>it can be avoided by purging the filenames (not the files!). 
>
>Nevertheless, the standard configuration of the Apache servers is
>basically unacceptable. It must execute user requests and never ever
>user files! Period.
>
>Have nice days,
>Niklaus 
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

Thanks,
Ash

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


Sorry for this late post but I'm amazed nobody consulted the doco.

The php.net site has a whole section titled "Handling File Uploads".
Also check out finfo_open and finfo_file.
If your are a windoze user you need a dll.
If you want Apache to handle PUT requests you MUST tell it to run a script as 
it cannot write to web root.

HTH

Robert

Re: [PHP] PHPDoc way to describe the magic getter/setters [SOLVED]

2013-09-25 Thread David Harkness
On Wed, Sep 25, 2013 at 4:31 PM, Daevid Vincent  wrote:

> Then I randomly stumbled upon this PHPDoc  @ method tag and my whole world
> is brighter today than it has been for the past, oh let's say DECADE!


Yes, @method and @property are very handy. Out of curiosity, since you're
providing magic getters and setters, why not use __get and __set instead of
__call with matching on "get_xxx" and "set_xxx"? This would allow using the
simpler (and IMHO much more expressive and PHP-ish) forms

$obj->foo = $obj->bar + 5;

Peace,
David


[PHP] PHPDoc way to describe the magic getter/setters [SOLVED]

2013-09-25 Thread Daevid Vincent
I use a base.class that most classes extend from. That class uses the lovely
Magic Methods for overloading __get() and __set()
http://php.net/manual/en/language.oop5.magic.php
 
However (in Zend Studio for example) when I try to auto-assist a property
$foo I don't see that it has a get() or set() method.
 
I'd like to see something like $this->get_foo() or $this->set_foo()  and
also if possible have them show up in the Outline tab window.
 
Then I randomly stumbled upon this PHPDoc  @ method tag and my whole world
is brighter today than it has been for the past, oh let's say DECADE!
http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags
.method.pkg.html
or @property too.
http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags
.property.pkg.html
 
*giddy!* 
(now I just have to go back through all my code and update the class
documentation headers everywhere)
 
http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags
.method.pkg.html
* @link
http://manual.phpdoc.org/HTMLSmartyConverter/PHP/phpDocumentor/tutorial_tags
.property.pkg.html
*/
class foo
{
   /**
   * @var string $name the description of $name goes here
   */
   protected $name;
 
   public function __construct($id = NULL)
   {
   }
}
 
$myobj = new foo();
 
 Put your cursor after the -> and hit CTRL+SPACE.
 Notice how you have "magic" get_name() and set_name($name)  
 appearing and also in the Eclipse "Outline" pane
 
$myobj->
 
 You're welcome. 
?>


Re: [PHP] Sending PHP mail with Authentication

2013-09-25 Thread Camilo Sperberg
On Wed, Sep 25, 2013 at 11:48 PM, Camilo Sperberg  wrote:
> Another vote for PHPMailer, I have it working several years already
> (authenticating against a Zimbra and Outlook SMTP server) without problems.
>
> Greetings.
>
>
> On Wed, Sep 25, 2013 at 11:12 PM, Aziz Saleh  wrote:
>>
>> Usually if I am using a framework I would use the SMTP library associated
>> with it. If it doesn't have one, I use phpmailer, fast and easy to setup:
>>
>> http://phpmailer.worxware.com/index.php?pg=examplebsmtp
>>
>> Aziz
>>
>>
>> On Wed, Sep 25, 2013 at 4:11 PM, dealTek  wrote:
>>
>> > Hi All,
>> >
>> > Semi newbie email question...
>> >
>> > I have used the - mail() — Send mail php function to send email from a
>> > site.
>> >
>> > now it seems the server is blocking this for safety because I should be
>> > using authentication
>> >
>> > Q: mail() does not have authentication - correct?
>> >
>> > Q: So I read from the link below that maybe I should use - PEAR Mail
>> > package  is this a good choice to send mail with authentication?
>> >
>> > ...any suggestions for basic sending email with authentication (setup
>> > info
>> > and links also) would be welcome
>> >
>> >
>> >
>> >
>> > http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
>> >
>> > --
>> > Thanks,
>> > Dave - DealTek
>> > deal...@gmail.com
>> > [db-3]
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>
>

Another vote for PHPMailer, I have it working several years already
(authenticating against a Zimbra and Outlook SMTP server) without
problems.

Greetings.

PD: Sorry for previous mail, it has been some time that I haven't used
the webmail interface of gmail :)

-- 
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www1: http://www.chw.net/
www2: http://unreal4u.com/

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



Re: [PHP] Sending PHP mail with Authentication

2013-09-25 Thread Camilo Sperberg
Another vote for PHPMailer, I have it working several years already
(authenticating against a Zimbra and Outlook SMTP server) without problems.

Greetings.


On Wed, Sep 25, 2013 at 11:12 PM, Aziz Saleh  wrote:

> Usually if I am using a framework I would use the SMTP library associated
> with it. If it doesn't have one, I use phpmailer, fast and easy to setup:
>
> http://phpmailer.worxware.com/index.php?pg=examplebsmtp
>
> Aziz
>
>
> On Wed, Sep 25, 2013 at 4:11 PM, dealTek  wrote:
>
> > Hi All,
> >
> > Semi newbie email question...
> >
> > I have used the - mail() — Send mail php function to send email from a
> > site.
> >
> > now it seems the server is blocking this for safety because I should be
> > using authentication
> >
> > Q: mail() does not have authentication - correct?
> >
> > Q: So I read from the link below that maybe I should use - PEAR Mail
> > package  is this a good choice to send mail with authentication?
> >
> > ...any suggestions for basic sending email with authentication (setup
> info
> > and links also) would be welcome
> >
> >
> >
> >
> http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
> >
> > --
> > Thanks,
> > Dave - DealTek
> > deal...@gmail.com
> > [db-3]
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>


Re: [PHP] Sending PHP mail with Authentication

2013-09-25 Thread Aziz Saleh
Usually if I am using a framework I would use the SMTP library associated
with it. If it doesn't have one, I use phpmailer, fast and easy to setup:

http://phpmailer.worxware.com/index.php?pg=examplebsmtp

Aziz


On Wed, Sep 25, 2013 at 4:11 PM, dealTek  wrote:

> Hi All,
>
> Semi newbie email question...
>
> I have used the - mail() — Send mail php function to send email from a
> site.
>
> now it seems the server is blocking this for safety because I should be
> using authentication
>
> Q: mail() does not have authentication - correct?
>
> Q: So I read from the link below that maybe I should use - PEAR Mail
> package  is this a good choice to send mail with authentication?
>
> ...any suggestions for basic sending email with authentication (setup info
> and links also) would be welcome
>
>
>
> http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
>
> --
> Thanks,
> Dave - DealTek
> deal...@gmail.com
> [db-3]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Sending PHP mail with Authentication

2013-09-25 Thread dealTek
Hi All,

Semi newbie email question...

I have used the - mail() — Send mail php function to send email from a site.

now it seems the server is blocking this for safety because I should be using 
authentication

Q: mail() does not have authentication - correct?

Q: So I read from the link below that maybe I should use - PEAR Mail package 
 is this a good choice to send mail with authentication?

...any suggestions for basic sending email with authentication (setup info and 
links also) would be welcome


http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm

--
Thanks,
Dave - DealTek
deal...@gmail.com
[db-3]


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



Re: [PHP] https question

2013-09-25 Thread Daniel Brown
On Wed, Sep 25, 2013 at 1:55 PM, Tedd Sperling  wrote:
> Hi gang:
>
> I have a client who had his entire site moved to another host -- no big 
> problem.
>
> However, the old site had a https directory, where I had secure scripts to do 
> credit-card transactions, but the new site doesn't have a https directory -- 
> in fact it doesn't even have a http directory at all. So, what options do I 
> have to do secure transactions?
>
> I remember someone saying that this could be done via a .htaccess file, but I 
> don't have the code, nor am I positive this is the answer.
>
> What do you recommend?

Sounds like it may have been moved from a Plesk server to a
non-Plesk server (or something using a similar path setup).  If it's
still Apache-based, yes, an .htaccess mod_rewrite directive should
suffice.  And, while it's out-of-scope for this list, an example, for
posterity:

# .htaccess - placed in the web root
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [QSA,R,L]


-- 

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

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



Re: [PHP] https question

2013-09-25 Thread Joshua Kehn
On Sep 25, 2013, at 2:24 PM, Tedd Sperling  wrote:
> 
> I understand that cc processing should be done via https.
> 
> Normally, that means to me that I place my $ scripts in a https directory -- 
> the problem is that I don't have one with this host.
> 
> So, I am asking how does one do that with a https directory?
> 
> Thanks,
> 
> tedd
> ___
> tedd sperling
> tedd.sperl...@gmail.com
> 


I'm saying the site should be served entirely under HTTPS. There shouldn't be 
separate https/http directories. Apache (or whatever your web server is) has a 
certificate installed on it and that vhost is configured to only respond to 
https requests. Typically this also means running a separate vhost on http that 
redirects to the https variant.

Where is this new host? It should be a dedicated box (vps or other) due to how 
the certificates need to be issued (dedicated ip address).

Best,

–Josh
____
Joshua Kehn | @joshkehn 
http://joshuakehn.com


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



  1   2   3   4   5   6   7   8   9   10   >