RE: [PHP] redirect to a page the fist time a site is accessed

2009-04-16 Thread Jencisson Tsu

hey,boy, i think you should use datebase to store user status,use user's 
internet-ip and intranet-ip to idenification.
> To: php-general@lists.php.net
> From: d...@program-it.ca
> Date: Wed, 15 Apr 2009 16:20:05 -0400
> Subject: Re: [PHP] redirect to a page the fist time a site is accessed
> 
> 
> "Andrew Ballard"  wrote in message 
> news:b6023aa40904150926g3e6fb478s36b18b6a53ec3...@mail.gmail.com...
> On Tue, Apr 14, 2009 at 10:30 PM, Jason Pruim  wrote:
> >
> >
> > On Apr 14, 2009, at 10:11 PM, "Don"  wrote:
> >
> >> Hi,
> >>
> >> I have some code in my index.php file that check the user agent and
> >> redirects to a warning page if IE 6 or less is encountered.
> >>
> >> 1. I'm using a framework and so calls to all pages go through index.php
> >> 2. The code that checks for IE 6 or less and redirects is in index.php
> >>
> >> I know how to redirect the users but what I want to do is redirect a user
> >> ONLY the first time the web site is accessed regardless of what page they
> >> first access. I would like to minimize overhead (no database). Can this
> >> be
> >> done?
> >>
> >> Thanks,
> >> Don
> >>
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> > Probably the best way I could think of would be to set a cookie on their
> > computer that you check for when they come and redirect based on that
> > cookie.
> >
> > It's not completely fail proof because all they have to do is clear 
> > cookies
> > and they will see it again but it should work for most people.
> 
> > Well, there is that ... and if the browser does not accept your
> > cookie, it will be trapped in an infinte redirection cycle.
> 
> > Andrew
> 
> Yes and from php.net,
> 
> "Cookies will not become visible until the next loading of a page that the 
> cookie should be visible for."
> 
> So there's no PHP solution for my problem?  I think I need to use unreliable 
> JavaScript. 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

_
Windows Live™: Life without walls.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1b_explore_042009

[PHP] problem with my class

2009-04-16 Thread Luke
Hi guys,

I've been learning about object oriented programming and I wrote this test
class but it doesn't seem to be working, it throws no errors but doesn't
insert anything to the database either. I have made sure that the data being
sent when the class is instantiated is valid.

I'm probably missing something simple here...

I have already

class RecipeCreator
{
private $rtitle;
private $problem;
private $solution;

function __construct ($t, $p, $s)
{
if(!isset($t, $p, $s))
{
throw new Exception ('Missing parameters for
__construct, need $title $problem and $solution');
}

$this->rtitle   = mysql_real_escape_string($t);
$this->problem  = mysql_real_escape_string($p);
$this->solution = mysql_real_escape_string($s);
}

public function saveRecipe()
{
$query = "INSERT INTO recipe (title, problem, solution)
VALUES ('".$this->rtitle."',

   '".$this->problem."',

   '".$this->solution."')";
mysql_query($query);
}
}

Many thanks,
Luke Slater


Re: [PHP] problem with my class

2009-04-16 Thread Jan G.B.
2009/4/16 Luke :
> Hi guys,
>
> I've been learning about object oriented programming and I wrote this test
> class but it doesn't seem to be working, it throws no errors but doesn't
> insert anything to the database either. I have made sure that the data being
> sent when the class is instantiated is valid.
>
> I'm probably missing something simple here...
>

Are you actually calling your public function?

$x = new RecipeCreator('a', 'b', 'c');
$x->saveRecipe();

You might want to insert some error reporting...

echo mysql_error(); and alike


Byebye




> I have already
>
> class RecipeCreator
> {
>        private $rtitle;
>        private $problem;
>        private $solution;
>
>        function __construct ($t, $p, $s)
>        {
>                if(!isset($t, $p, $s))
>                {
>                        throw new Exception ('Missing parameters for
> __construct, need $title $problem and $solution');
>                }
>
>                $this->rtitle   = mysql_real_escape_string($t);
>                $this->problem  = mysql_real_escape_string($p);
>                $this->solution = mysql_real_escape_string($s);
>        }
>
>        public function saveRecipe()
>        {
>                $query = "INSERT INTO recipe (title, problem, solution)
> VALUES ('".$this->rtitle."',
>
>   '".$this->problem."',
>
>   '".$this->solution."')";
>                mysql_query($query);
>        }
> }
>
> Many thanks,
> Luke Slater
>

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



[PHP] modified list of simplified Chinese

2009-04-16 Thread cr.vegelin
Hi List,

Not PHP specific, but maybe of interest for you ...

BEIJING, April 9
For the first time in nearly 20 years, China will issue a modified list of 
simplified Chinese characters 
in an effort to further standardize a language used by billions around the 
world.

More at: http://news.xinhuanet.com/english/2009-04/09/content_11157349.htm

Regards, Cor

Re: [PHP] redirect to a page the fist time a site is accessed

2009-04-16 Thread Stuart
2009/4/15 Don :
> I have some code in my index.php file that check the user agent and
> redirects to a warning page if IE 6 or less is encountered.
>
> 1. I'm using a framework and so calls to all pages go through index.php
> 2. The code that checks for IE 6 or less and redirects is in index.php
>
> I know how to redirect the users but what I want to do is redirect a user
> ONLY the first time the web site is accessed regardless of what page they
> first access.  I would like to minimize overhead (no database).  Can this be
> done?

Why redirect? That sucks as a user experience. Why not simply put an
alert somewhere prominent on the page with the message you want to
convey? That way you can have it on every page and not interrupt the
users use of your site.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] problem with my class

2009-04-16 Thread Luke
2009/4/16 Jan G.B. 

> 2009/4/16 Luke :
> > Hi guys,
> >
> > I've been learning about object oriented programming and I wrote this
> test
> > class but it doesn't seem to be working, it throws no errors but doesn't
> > insert anything to the database either. I have made sure that the data
> being
> > sent when the class is instantiated is valid.
> >
> > I'm probably missing something simple here...
> >
>
> Are you actually calling your public function?
>
> $x = new RecipeCreator('a', 'b', 'c');
> $x->saveRecipe();
>
> You might want to insert some error reporting...
>
> echo mysql_error(); and alike
>
>
> Byebye
>
>
>
>
> > I have already
> >
> > class RecipeCreator
> > {
> >private $rtitle;
> >private $problem;
> >private $solution;
> >
> >function __construct ($t, $p, $s)
> >{
> >if(!isset($t, $p, $s))
> >{
> >throw new Exception ('Missing parameters for
> > __construct, need $title $problem and $solution');
> >}
> >
> >$this->rtitle   = mysql_real_escape_string($t);
> >$this->problem  = mysql_real_escape_string($p);
> >$this->solution = mysql_real_escape_string($s);
> >}
> >
> >public function saveRecipe()
> >{
> >$query = "INSERT INTO recipe (title, problem, solution)
> > VALUES ('".$this->rtitle."',
> >
> >   '".$this->problem."',
> >
> >   '".$this->solution."')";
> >mysql_query($query);
> >}
> > }
> >
> > Many thanks,
> > Luke Slater
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Yes I am doing that. The query seems to be going through all right too I
tested the syntax in mysql query browser and tried mysql_error() but there
was nothing.
I think there's an issue with the __construct because when I wrote a method
in there to return one of the properties of the function, it turned up
blank! As I said before the variables I'm passing in are definitely valid...


Re: [PHP] redirect to a page the fist time a site is accessed

2009-04-16 Thread Igor Escobar
I Agree with @stuart.


Regards,
Igor Escoar
Systems Analyst & Interface Designer

--

Personal Blog
~ blog.igorescobar.com
Online Portifolio
~ www.igorescobar.com
Twitter
~ @igorescobar





On Thu, Apr 16, 2009 at 6:05 AM, Stuart  wrote:

> 2009/4/15 Don :
> > I have some code in my index.php file that check the user agent and
> > redirects to a warning page if IE 6 or less is encountered.
> >
> > 1. I'm using a framework and so calls to all pages go through index.php
> > 2. The code that checks for IE 6 or less and redirects is in index.php
> >
> > I know how to redirect the users but what I want to do is redirect a user
> > ONLY the first time the web site is accessed regardless of what page they
> > first access.  I would like to minimize overhead (no database).  Can this
> be
> > done?
>
> Why redirect? That sucks as a user experience. Why not simply put an
> alert somewhere prominent on the page with the message you want to
> convey? That way you can have it on every page and not interrupt the
> users use of your site.
>
> -Stuart
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


RE: [PHP] ftp_put issues

2009-04-16 Thread James
Hi, yeah ftp manually works just fine using the same login too.

James

-Original Message-
From: Chris [mailto:dmag...@gmail.com] 
Sent: Wednesday, April 15, 2009 10:09 PM
To: James
Cc: php-general@lists.php.net
Subject: Re: [PHP] ftp_put issues

James wrote:
> Hi, I'm trying to upload a pdf file from a local drive to the server using
a 
> php routine. I've done it server to server before with no issues but this 
> just keeps failing on me.
> 
> This is the function I'm calling, it connects and logs in just fine, but
it 
> will not upload the file. The file I'm sending is just a 100k pdf file.

If you do it manually does it work? Maybe the account is over quota.

-- 
Postgresql & php tutorials
http://www.designmagick.com/


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



Re: [PHP] problem with my class

2009-04-16 Thread Thijs Lensselink
Luke wrote:
> 2009/4/16 Jan G.B. 
> 
>> 2009/4/16 Luke :
>>> Hi guys,
>>>
>>> I've been learning about object oriented programming and I wrote this
>> test
>>> class but it doesn't seem to be working, it throws no errors but doesn't
>>> insert anything to the database either. I have made sure that the data
>> being
>>> sent when the class is instantiated is valid.
>>>
>>> I'm probably missing something simple here...
>>>
>> Are you actually calling your public function?
>>
>> $x = new RecipeCreator('a', 'b', 'c');
>> $x->saveRecipe();
>>
>> You might want to insert some error reporting...
>>
>> echo mysql_error(); and alike
>>
>>
>> Byebye
>>
>>
>>
>>
>>> I have already
>>>
>>> class RecipeCreator
>>> {
>>>private $rtitle;
>>>private $problem;
>>>private $solution;
>>>
>>>function __construct ($t, $p, $s)
>>>{
>>>if(!isset($t, $p, $s))
>>>{
>>>throw new Exception ('Missing parameters for
>>> __construct, need $title $problem and $solution');
>>>}
>>>
>>>$this->rtitle   = mysql_real_escape_string($t);
>>>$this->problem  = mysql_real_escape_string($p);
>>>$this->solution = mysql_real_escape_string($s);
>>>}
>>>
>>>public function saveRecipe()
>>>{
>>>$query = "INSERT INTO recipe (title, problem, solution)
>>> VALUES ('".$this->rtitle."',
>>>
>>>   '".$this->problem."',
>>>
>>>   '".$this->solution."')";
>>>mysql_query($query);
>>>}
>>> }
>>>
>>> Many thanks,
>>> Luke Slater
>>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
> Yes I am doing that. The query seems to be going through all right too I
> tested the syntax in mysql query browser and tried mysql_error() but there
> was nothing.
> I think there's an issue with the __construct because when I wrote a method
> in there to return one of the properties of the function, it turned up
> blank! As I said before the variables I'm passing in are definitely valid...
> 

And what happens when you instantiate your object without parameters?

$foo = new RecipeCreator();

It should throw and exception. This way you at least know if your
constructor is functioning properly.

And take a look at the message you throw when the parameters are not
set. The parameters are named $t, $p, $s but the message in the throw
statement uses $title, $problem, $solution

did you try echoing out the query and run it from phpMyAdmin or
something similar?

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



Re: [PHP] problem with my class

2009-04-16 Thread Luke Slater
On Thu, Apr 16, 2009 at 2:41 PM, Thijs Lensselink wrote:

> Luke wrote:
> > 2009/4/16 Jan G.B. 
> >
> >> 2009/4/16 Luke :
> >>> Hi guys,
> >>>
> >>> I've been learning about object oriented programming and I wrote this
> >> test
> >>> class but it doesn't seem to be working, it throws no errors but
> doesn't
> >>> insert anything to the database either. I have made sure that the data
> >> being
> >>> sent when the class is instantiated is valid.
> >>>
> >>> I'm probably missing something simple here...
> >>>
> >> Are you actually calling your public function?
> >>
> >> $x = new RecipeCreator('a', 'b', 'c');
> >> $x->saveRecipe();
> >>
> >> You might want to insert some error reporting...
> >>
> >> echo mysql_error(); and alike
> >>
> >>
> >> Byebye
> >>
> >>
> >>
> >>
> >>> I have already
> >>>
> >>> class RecipeCreator
> >>> {
> >>>private $rtitle;
> >>>private $problem;
> >>>private $solution;
> >>>
> >>>function __construct ($t, $p, $s)
> >>>{
> >>>if(!isset($t, $p, $s))
> >>>{
> >>>throw new Exception ('Missing parameters for
> >>> __construct, need $title $problem and $solution');
> >>>}
> >>>
> >>>$this->rtitle   = mysql_real_escape_string($t);
> >>>$this->problem  = mysql_real_escape_string($p);
> >>>$this->solution = mysql_real_escape_string($s);
> >>>}
> >>>
> >>>public function saveRecipe()
> >>>{
> >>>$query = "INSERT INTO recipe (title, problem, solution)
> >>> VALUES ('".$this->rtitle."',
> >>>
> >>>   '".$this->problem."',
> >>>
> >>>   '".$this->solution."')";
> >>>mysql_query($query);
> >>>}
> >>> }
> >>>
> >>> Many thanks,
> >>> Luke Slater
> >>>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > Yes I am doing that. The query seems to be going through all right too I
> > tested the syntax in mysql query browser and tried mysql_error() but
> there
> > was nothing.
> > I think there's an issue with the __construct because when I wrote a
> method
> > in there to return one of the properties of the function, it turned up
> > blank! As I said before the variables I'm passing in are definitely
> valid...
> >
>
> And what happens when you instantiate your object without parameters?
>
> $foo = new RecipeCreator();
>
> It should throw and exception. This way you at least know if your
> constructor is functioning properly.
>
> And take a look at the message you throw when the parameters are not
> set. The parameters are named $t, $p, $s but the message in the throw
> statement uses $title, $problem, $solution
>
> did you try echoing out the query and run it from phpMyAdmin or
> something similar?
>

I changed the variables to $t $p and $s because I thought by naming them
with $title $problem and $solution may have been getting them mixed up
somehow.

I figured out the problem, which was that I was actually calling the
saveRecipe() method without the parentheses.

Too long programming in Perl -.-

Thanks for your help,

Luke Slater


Re: [PHP] problem with my class

2009-04-16 Thread Thijs Lensselink
Luke Slater wrote:
> On Thu, Apr 16, 2009 at 2:41 PM, Thijs Lensselink  > wrote:
> 
> Luke wrote:
> > 2009/4/16 Jan G.B.  >
> >
> >> 2009/4/16 Luke mailto:l...@blog-thing.com>>:
> >>> Hi guys,
> >>>
> >>> I've been learning about object oriented programming and I wrote
> this
> >> test
> >>> class but it doesn't seem to be working, it throws no errors but
> doesn't
> >>> insert anything to the database either. I have made sure that
> the data
> >> being
> >>> sent when the class is instantiated is valid.
> >>>
> >>> I'm probably missing something simple here...
> >>>
> >> Are you actually calling your public function?
> >>
> >> $x = new RecipeCreator('a', 'b', 'c');
> >> $x->saveRecipe();
> >>
> >> You might want to insert some error reporting...
> >>
> >> echo mysql_error(); and alike
> >>
> >>
> >> Byebye
> >>
> >>
> >>
> >>
> >>> I have already
> >>>
> >>> class RecipeCreator
> >>> {
> >>>private $rtitle;
> >>>private $problem;
> >>>private $solution;
> >>>
> >>>function __construct ($t, $p, $s)
> >>>{
> >>>if(!isset($t, $p, $s))
> >>>{
> >>>throw new Exception ('Missing parameters for
> >>> __construct, need $title $problem and $solution');
> >>>}
> >>>
> >>>$this->rtitle   = mysql_real_escape_string($t);
> >>>$this->problem  = mysql_real_escape_string($p);
> >>>$this->solution = mysql_real_escape_string($s);
> >>>}
> >>>
> >>>public function saveRecipe()
> >>>{
> >>>$query = "INSERT INTO recipe (title, problem,
> solution)
> >>> VALUES ('".$this->rtitle."',
> >>>
> >>>   '".$this->problem."',
> >>>
> >>>   '".$this->solution."')";
> >>>mysql_query($query);
> >>>}
> >>> }
> >>>
> >>> Many thanks,
> >>> Luke Slater
> >>>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > Yes I am doing that. The query seems to be going through all right
> too I
> > tested the syntax in mysql query browser and tried mysql_error()
> but there
> > was nothing.
> > I think there's an issue with the __construct because when I wrote
> a method
> > in there to return one of the properties of the function, it turned up
> > blank! As I said before the variables I'm passing in are
> definitely valid...
> >
> 
> And what happens when you instantiate your object without parameters?
> 
> $foo = new RecipeCreator();
> 
> It should throw and exception. This way you at least know if your
> constructor is functioning properly.
> 
> And take a look at the message you throw when the parameters are not
> set. The parameters are named $t, $p, $s but the message in the throw
> statement uses $title, $problem, $solution
> 
> did you try echoing out the query and run it from phpMyAdmin or
> something similar?
> 
> 
> I changed the variables to $t $p and $s because I thought by naming them
> with $title $problem and $solution may have been getting them mixed up
> somehow.
> 
> I figured out the problem, which was that I was actually calling the
> saveRecipe() method without the parentheses.

Happens to the best :)

> 
> Too long programming in Perl -.-
> 
> Thanks for your help,
> 
> Luke Slater

Great you figured it out.

Regards,
Thijs

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



Re: [PHP] ftp_put issues

2009-04-16 Thread j's php general
On Thu, Apr 16, 2009 at 9:27 PM, James  wrote:
> Hi, yeah ftp manually works just fine using the same login too.
>
> James
>
> -Original Message-
> From: Chris [mailto:dmag...@gmail.com]
> Sent: Wednesday, April 15, 2009 10:09 PM
> To: James
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] ftp_put issues
>
> James wrote:
>> Hi, I'm trying to upload a pdf file from a local drive to the server using
> a
>> php routine. I've done it server to server before with no issues but this
>> just keeps failing on me.
>>
>> This is the function I'm calling, it connects and logs in just fine, but
> it
>> will not upload the file. The file I'm sending is just a 100k pdf file.
>
> If you do it manually does it work? Maybe the account is over quota.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Just to be clear where are you running your ftpData function from?
Your local computer? Where is the PDF file coming from? I hope from
your local computer as well.

How does your Source and Dest variables look like? Full paths?
Have you tried your firewall? (Assuming both script and file is coming
from local and your firewall is on whitelist mode.)

Cheers

-- 
http://www.lampadmins.com

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



Re: [PHP] redirect to a page the fist time a site is accessed

2009-04-16 Thread Shawn McKenzie
Stuart wrote:
> 2009/4/15 Don :
>> I have some code in my index.php file that check the user agent and
>> redirects to a warning page if IE 6 or less is encountered.
>>
>> 1. I'm using a framework and so calls to all pages go through index.php
>> 2. The code that checks for IE 6 or less and redirects is in index.php
>>
>> I know how to redirect the users but what I want to do is redirect a user
>> ONLY the first time the web site is accessed regardless of what page they
>> first access.  I would like to minimize overhead (no database).  Can this be
>> done?
> 
> Why redirect? That sucks as a user experience. Why not simply put an
> alert somewhere prominent on the page with the message you want to
> convey? That way you can have it on every page and not interrupt the
> users use of your site.

I agree, and you can still try the cookie method to not show the
message, but it's not a big deal if they don't get the cookie/it expires
etc., because the worst thing that can happen is that they see the message.


> 
> -Stuart
> 


-- 
Thanks!
-Shawn
http://www.spidean.com

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



RE: [PHP] ftp_put issues

2009-04-16 Thread James Hill
The ftpData function and in fact all the php stuff is running online on my
webserver. The pdf file is on my local machine, I'm trying to upload the
local pdf file to the server using ftp.

 

The dest variable I have tried with the full path:

/var/www/html/Docs/DU/DU1.pdf

And with just the DU1.pdf along with ftp_chdir.

 

The local file path is being passed through a html form and consists of
L:/mypdfs/testpdf.pdf

 

I've disabled my firewall to try that to no avail.

 

James

 

-Original Message-
From: j's php general [mailto:php-generals-php-dot-...@jhive.net] 
Sent: Thursday, April 16, 2009 10:07 AM
To: James
Cc: php-general@lists.php.net
Subject: Re: [PHP] ftp_put issues

 

On Thu, Apr 16, 2009 at 9:27 PM, James  wrote:

> Hi, yeah ftp manually works just fine using the same login too.

> 

> James

> 

> -Original Message-

> From: Chris [mailto:dmag...@gmail.com]

> Sent: Wednesday, April 15, 2009 10:09 PM

> To: James

> Cc: php-general@lists.php.net

> Subject: Re: [PHP] ftp_put issues

> 

> James wrote:

>> Hi, I'm trying to upload a pdf file from a local drive to the server
using

> a

>> php routine. I've done it server to server before with no issues but this

>> just keeps failing on me.

>> 

>> This is the function I'm calling, it connects and logs in just fine, but

> it

>> will not upload the file. The file I'm sending is just a 100k pdf file.

> 

> If you do it manually does it work? Maybe the account is over quota.

> 

> --

> Postgresql & php tutorials

> http://www.designmagick.com/

> 

> 

> --

> PHP General Mailing List (http://www.php.net/)

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

> 

> 

 

Just to be clear where are you running your ftpData function from?

Your local computer? Where is the PDF file coming from? I hope from

your local computer as well.

 

How does your Source and Dest variables look like? Full paths?

Have you tried your firewall? (Assuming both script and file is coming

from local and your firewall is on whitelist mode.)

 

Cheers

 

-- 

http://www.lampadmins.com



RE: [PHP] problem with my class

2009-04-16 Thread abdulazeez alugo


 

> Date: Thu, 16 Apr 2009 14:43:46 +0100
> From: l...@blog-thing.com
> To: p...@addmissions.nl
> CC: ro0ot.w...@googlemail.com; php-general@lists.php.net
> Subject: Re: [PHP] problem with my class
> 
> On Thu, Apr 16, 2009 at 2:41 PM, Thijs Lensselink wrote:
> 
> > Luke wrote:
> > > 2009/4/16 Jan G.B. 
> > >
> > >> 2009/4/16 Luke :
> > >>> Hi guys,
> > >>>
> > >>> I've been learning about object oriented programming and I wrote this
> > >> test
> > >>> class but it doesn't seem to be working, it throws no errors but
> > doesn't
> > >>> insert anything to the database either. I have made sure that the data
> > >> being
> > >>> sent when the class is instantiated is valid.
> > >>>
> > >>> I'm probably missing something simple here...
> > >>>
> > >> Are you actually calling your public function?
> > >>
> > >> $x = new RecipeCreator('a', 'b', 'c');
> > >> $x->saveRecipe();
> > >>
> > >> You might want to insert some error reporting...
> > >>
> > >> echo mysql_error(); and alike
> > >>
> > >>
> > >> Byebye
> > >>
> > >>
> > >>
> > >>
> > >>> I have already
> > >>>
> > >>> class RecipeCreator
> > >>> {
> > >>> private $rtitle;
> > >>> private $problem;
> > >>> private $solution;
> > >>>
> > >>> function __construct ($t, $p, $s)
> > >>> {
> > >>> if(!isset($t, $p, $s))
> > >>> {
> > >>> throw new Exception ('Missing parameters for
> > >>> __construct, need $title $problem and $solution');
> > >>> }
> > >>>
> > >>> $this->rtitle = mysql_real_escape_string($t);
> > >>> $this->problem = mysql_real_escape_string($p);
> > >>> $this->solution = mysql_real_escape_string($s);
> > >>> }
> > >>>
> > >>> public function saveRecipe()
> > >>> {
> > >>> $query = "INSERT INTO recipe (title, problem, solution)
> > >>> VALUES ('".$this->rtitle."',
> > >>>
> > >>> '".$this->problem."',
> > >>>
> > >>> '".$this->solution."')";
> > >>> mysql_query($query);
> > >>> }
> > >>> }
> > >>>
> > >>> Many thanks,
> > >>> Luke Slater
> > >>>
> > >> --
> > >> PHP General Mailing List (http://www.php.net/)
> > >> To unsubscribe, visit: http://www.php.net/unsub.php
> > >>
> > >>
> > >
> > > Yes I am doing that. The query seems to be going through all right too I
> > > tested the syntax in mysql query browser and tried mysql_error() but
> > there
> > > was nothing.
> > > I think there's an issue with the __construct because when I wrote a
> > method
> > > in there to return one of the properties of the function, it turned up
> > > blank! As I said before the variables I'm passing in are definitely
> > valid...
> > >
> >
> > And what happens when you instantiate your object without parameters?
> >
> > $foo = new RecipeCreator();
> >
> > It should throw and exception. This way you at least know if your
> > constructor is functioning properly.
> >
> > And take a look at the message you throw when the parameters are not
> > set. The parameters are named $t, $p, $s but the message in the throw
> > statement uses $title, $problem, $solution
> >
> > did you try echoing out the query and run it from phpMyAdmin or
> > something similar?
> >
> 
> I changed the variables to $t $p and $s because I thought by naming them
> with $title $problem and $solution may have been getting them mixed up
> somehow.
> 
> I figured out the problem, which was that I was actually calling the
> saveRecipe() method without the parentheses.
> 
> Too long programming in Perl -.-
> 
> Thanks for your help,
> 
> Luke Slater

 

Hi Luke,

class RecipeCreator
 {
 private $rtitle;
private $problem;
private $solution;

function __construct ($t, $p, $s)
 {
if(!isset($t, $p, $s))
 {
 throw new Exception ('Missing parameters for
 __construct, need $title $problem and $solution');
 }

I think the problem was with the $title. As above, you defined the private 
variable $rtitle but you were trying to call the variable later as $title.

 

Cheers.

Alugo Abdulazeez.


_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

Re: [PHP] ftp_put issues

2009-04-16 Thread j's php general
On Thu, Apr 16, 2009 at 10:24 PM, James Hill
 wrote:
> The ftpData function and in fact all the php stuff is running online on my
> webserver. The pdf file is on my local machine, I'm trying to upload the
> local pdf file to the server using ftp.
>
>
>
> The dest variable I have tried with the full path:
>
> /var/www/html/Docs/DU/DU1.pdf
>
> And with just the DU1.pdf along with ftp_chdir.
>
>
>
> The local file path is being passed through a html form and consists of
> L:/mypdfs/testpdf.pdf
>
>
>
> I've disabled my firewall to try that to no avail.
>
>
>
> James
>
>
>
> Just to be clear where are you running your ftpData function from?
>
> Your local computer? Where is the PDF file coming from? I hope from
>
> your local computer as well.
>
>
>
> How does your Source and Dest variables look like? Full paths?
>
> Have you tried your firewall? (Assuming both script and file is coming
>
> from local and your firewall is on whitelist mode.)
>
>
>
> Cheers
>
>
>
> --
>
> http://www.lampadmins.com

I think that explains your problem, in order to upload a file via FTP
your FTP client GENERALLY must reside on the same computer as your
client, in your case your FTP client sits remotely elsewhere (which is
your PHP script) and your file is on your local computer.

A simple HTTP file upload should fit your 100K file nicely.

Cheers.

-- 
http://www.lampadmins.com

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



RE: [PHP] ftp_put issues

2009-04-16 Thread James Hill
Ah ok, I guess that would explain it. Thanks for your help :-)

-Original Message-
From: j's php general [mailto:php-generals-php-dot-...@jhive.net] 
Sent: Thursday, April 16, 2009 10:39 AM
To: James Hill
Cc: php-general@lists.php.net
Subject: Re: [PHP] ftp_put issues

On Thu, Apr 16, 2009 at 10:24 PM, James Hill
 wrote:
> The ftpData function and in fact all the php stuff is running online on my
> webserver. The pdf file is on my local machine, I'm trying to upload the
> local pdf file to the server using ftp.
>
>
>
> The dest variable I have tried with the full path:
>
> /var/www/html/Docs/DU/DU1.pdf
>
> And with just the DU1.pdf along with ftp_chdir.
>
>
>
> The local file path is being passed through a html form and consists of
> L:/mypdfs/testpdf.pdf
>
>
>
> I've disabled my firewall to try that to no avail.
>
>
>
> James
>
>
>
> Just to be clear where are you running your ftpData function from?
>
> Your local computer? Where is the PDF file coming from? I hope from
>
> your local computer as well.
>
>
>
> How does your Source and Dest variables look like? Full paths?
>
> Have you tried your firewall? (Assuming both script and file is coming
>
> from local and your firewall is on whitelist mode.)
>
>
>
> Cheers
>
>
>
> --
>
> http://www.lampadmins.com

I think that explains your problem, in order to upload a file via FTP
your FTP client GENERALLY must reside on the same computer as your
client, in your case your FTP client sits remotely elsewhere (which is
your PHP script) and your file is on your local computer.

A simple HTTP file upload should fit your 100K file nicely.

Cheers.

-- 
http://www.lampadmins.com


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



Re: [PHP] problem with my class

2009-04-16 Thread Jan G.B.
2009/4/16 abdulazeez alugo :
>
>
>> Date: Thu, 16 Apr 2009 14:43:46 +0100
>> From: l...@blog-thing.com
>> To: p...@addmissions.nl
>> CC: ro0ot.w...@googlemail.com; php-general@lists.php.net
>> Subject: Re: [PHP] problem with my class
>>
>> On Thu, Apr 16, 2009 at 2:41 PM, Thijs Lensselink
>> wrote:
>>
>> > Luke wrote:
>> > > 2009/4/16 Jan G.B. 
>> > >
>> > >> 2009/4/16 Luke :
>> > >>> Hi guys,
>> > >>>
>> > >>> I've been learning about object oriented programming and I wrote
>> > >>> this
>> > >> test
>> > >>> class but it doesn't seem to be working, it throws no errors but
>> > doesn't
>> > >>> insert anything to the database either. I have made sure that the
>> > >>> data
>> > >> being
>> > >>> sent when the class is instantiated is valid.
>> > >>>
>> > >>> I'm probably missing something simple here...
>> > >>>
>> > >> Are you actually calling your public function?
>> > >>
>> > >> $x = new RecipeCreator('a', 'b', 'c');
>> > >> $x->saveRecipe();
>> > >>
>> > >> You might want to insert some error reporting...
>> > >>
>> > >> echo mysql_error(); and alike
>> > >>
>> > >>
>> > >> Byebye
>> > >>
>> > >>
>> > >>
>> > >>
>> > >>> I have already
>> > >>>
>> > >>> class RecipeCreator
>> > >>> {
>> > >>> private $rtitle;
>> > >>> private $problem;
>> > >>> private $solution;
>> > >>>
>> > >>> function __construct ($t, $p, $s)
>> > >>> {
>> > >>> if(!isset($t, $p, $s))
>> > >>> {
>> > >>> throw new Exception ('Missing parameters for
>> > >>> __construct, need $title $problem and $solution');
>> > >>> }
>> > >>>
>> > >>> $this->rtitle = mysql_real_escape_string($t);
>> > >>> $this->problem = mysql_real_escape_string($p);
>> > >>> $this->solution = mysql_real_escape_string($s);
>> > >>> }
>> > >>>
>> > >>> public function saveRecipe()
>> > >>> {
>> > >>> $query = "INSERT INTO recipe (title, problem, solution)
>> > >>> VALUES ('".$this->rtitle."',
>> > >>>
>> > >>> '".$this->problem."',
>> > >>>
>> > >>> '".$this->solution."')";
>> > >>> mysql_query($query);
>> > >>> }
>> > >>> }
>> > >>>
>> > >>> Many thanks,
>> > >>> Luke Slater
>> > >>>
>> > >> --
>> > >> PHP General Mailing List (http://www.php.net/)
>> > >> To unsubscribe, visit: http://www.php.net/unsub.php
>> > >>
>> > >>
>> > >
>> > > Yes I am doing that. The query seems to be going through all right too
>> > > I
>> > > tested the syntax in mysql query browser and tried mysql_error() but
>> > there
>> > > was nothing.
>> > > I think there's an issue with the __construct because when I wrote a
>> > method
>> > > in there to return one of the properties of the function, it turned up
>> > > blank! As I said before the variables I'm passing in are definitely
>> > valid...
>> > >
>> >
>> > And what happens when you instantiate your object without parameters?
>> >
>> > $foo = new RecipeCreator();
>> >
>> > It should throw and exception. This way you at least know if your
>> > constructor is functioning properly.
>> >
>> > And take a look at the message you throw when the parameters are not
>> > set. The parameters are named $t, $p, $s but the message in the throw
>> > statement uses $title, $problem, $solution
>> >
>> > did you try echoing out the query and run it from phpMyAdmin or
>> > something similar?
>> >
>>
>> I changed the variables to $t $p and $s because I thought by naming them
>> with $title $problem and $solution may have been getting them mixed up
>> somehow.
>>
>> I figured out the problem, which was that I was actually calling the
>> saveRecipe() method without the parentheses.
>>
>> Too long programming in Perl -.-
>>
>> Thanks for your help,
>>
>> Luke Slater
>
> Hi Luke,
> class RecipeCreator
>  {
>  private $rtitle;
> private $problem;
> private $solution;
>
> function __construct ($t, $p, $s)
>  {
> if(!isset($t, $p, $s))
>  {
>  throw new Exception ('Missing parameters for
>  __construct, need $title $problem and $solution');
>  }
> I think the problem was with the $title. As above, you defined the private
> variable $rtitle but you were trying to call the variable later as $title.
>


The problem was already solved. But I feel like mentioning, that the
Exeption is just "naming" the variables with their content...
the class reads the vars as $t, $p and $s and it dowsn't matter at all
if you call ist with new foo($BAR, $whatever,
$somethingveryverydifferent), as once in the class only the VALUES
count. and yey're being assigned to the function vars $p, $t, $s,
which are being set to PRIVATE vars $rtitle, $problem etc.
Conclusion: The variable handling has no errors!

byebye



> Cheers.
> Alugo Abdulazeez.
>
>
> 
> Get news, entertainment and everything you care about at Live.com. Check it
> out!

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



Re: [PHP] problem with my class

2009-04-16 Thread Jan G.B.
Excuse my bad spelling. I should have read the message again before
hitting send. :-)


2009/4/16 Jan G.B. :
>> I think the problem was with the $title. As above, you defined the private
>> variable $rtitle but you were trying to call the variable later as $title.
>>
>
>
> The problem was already solved. But I feel like mentioning, that the
> Exeption is just "naming" the variables with their content...
> the class reads the vars as $t, $p and $s and it dowsn't matter at all
> if you call ist with new foo($BAR, $whatever,
> $somethingveryverydifferent), as once in the class only the VALUES
> count. and yey're being assigned to the function vars $p, $t, $s,
> which are being set to PRIVATE vars $rtitle, $problem etc.
> Conclusion: The variable handling has no errors!
>
> byebye

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



Re: [PHP] cURL - Error 400

2009-04-16 Thread haliphax
On Wed, Apr 15, 2009 at 9:17 PM, David  wrote:
> Except I also need to POST data to the server to login. After I've logged
> in, I then need to use cookies to maintain a session.
>
> Doing that via file_get_contents() just isn't possible.
>
>
> Thanks
>
> On Thu, Apr 16, 2009 at 2:30 AM, haliphax  wrote:
>>
>> On Wed, Apr 15, 2009 at 10:36 AM, David  wrote:
>> > I was wondering if anyone could please help me with this cURL script
>> > since I
>> > keep getting error 400 from the web server:
>> >
>> > http://pastebin.ca/1392840
>> >
>> > It worked until around a month ago which is when they presumably made
>> > changes to the site. Except I can't figure out what configuration option
>> > in
>> > the cURL PHP script needs to be changed. I can visit the site perfectly
>> > in
>> > Lynx, Firefox and IE.
>>
>> Are you just trying to get the contents of the page, or is there
>> something special you're doing? If it's just the contents you're
>> after, try file_get_contents() if allow_url_fopen is set to TRUE for
>> your PHP installation.
>>
>> http://php.net/file_get_contents
>> http://php.net/allow_url_fopen

David, please refrain from top-posting.

As for cURL login/session handling... I have an automated script that
connects to a phpBB bulletin board, and here are the settings that
have worked for me:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_COOKIEFILE, "{$homedir}cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "{$homedir}cookiefile");
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());

I would think CURLOPT_FOLLOWLOCATION and the CURLOPT_COOKIE* options
are most important for resolving your issue.

HTH,


-- 
// Todd

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



RE: [PHP] PDO fetch_obj - question

2009-04-16 Thread MEM
 
Thanks. I will see. The script for my database was been generated so, I will
doublecheck this uppercase "issue"...

Regards,
Márcio
2009/4/15 Thodoris 
 
Hi there,  I’ve made a fetch_obj and, as stated on some sites, it returns a
anonymous
object where the properties will have the name of our columns database.
However, when I do this, I notice that instead of giving me the column names
as they are typed on the DB I get them uppercase. So, when my database field
is “id_dog” to retrieve the property properly I have to search for “ID_DOG”
 Why is this? Is this a normal behavior?
  Thanks a lot,
Márcio

 
I have just dumped an object using var_dump retrieved with pdo fetch object
method:

object(stdClass)#3 (4) {
 ["id"]=>
 string(1) "1"
 ["cat"]=>
 string(1) "1"
 ["cod_sin"]=>
 string(6) "120014"
 ["cod_uis"]=>
 string(2) "26"
}


and it seems quite normal to me. Try to see your table info using:

describe `tablename`;

To see what are your table's fields .

Try to include more info about your system, php version etc in case you
reply. It will help us to help you.

-- 
Thodoris
 
Done. No problem at all. The scripts as generated the database columns with
uppercase. 
 
;)
 
Thanks for the info Thodoris.
 
 
Regards,
Marcio
 
 


Re: [PHP] alt() - unknown function?

2009-04-16 Thread Nitsan Bin-Nun
alt sounds like alternator ;)

On Wed, Apr 15, 2009 at 10:00 PM, Paul M Foster wrote:

> On Wed, Apr 15, 2009 at 03:23:19PM +0100, Tom Calpin wrote:
>
> > Hi all,
> >
> > I've just started looking at the code of an e-commerce site we are taking
> > over the development of, that another company has previously developed .
> > Coupled with the difficulty of taking over development of someone else's
> > code (also poorly commented), I've been stumped by a fatal error on a
> > function call alt() which is dotted everywhere in the main templating
> script
> > (sample below):
> >
> > // Get/Set a specific property of a page
> > function getPageProp($prop,$id="") { return
> > $this->PAGES[alt($id,$this->getPageID())][$prop]; }
> > function setPageProp($prop,$val,$id="") {
> > $this->PAGES[alt($id,$this->getPageID())][$prop]=$val; }
> >
> > It looks to be defining properties for a list of pages, with each page
> > providing its own PageID.
> >
> > I've never seen this function before, nor can I find any definition of it
> in
> > the site code, I was wondering if anyone recognises this, is it from a
> > thirdparty templating tool at all?
>
> It's been suggested you do a thorough search for this function, but the
> fact that PHP isn't finding it in the first place leads me to believe it
> isn't there. If that's the case, I'd suggest you make up your own alt()
> function that does what you think this one is doing (maybe just return
> the passed variable). You'll have to decide where to put it that's
> visible in all the places where it's called.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] bug or expected, mbstring.func_overload not changeable by .htaccess 5.2.8/5.2.9

2009-04-16 Thread Andre Hübner

Hello,


Besides the .htaccess which might be an apache configuration problem if
you use ini_set("mbstring.func_overload",2) in a script of this
directory does it work?

no, also the ini_set does not work for this Directive.


In addition to this heck your apache configuration to see if you allow
.htaccess to be parsed.


apache and .htaccess are ok
i added a scond line which changes mbstring.encoding_translation from off to 
on without problems:


Directive Local Value Master Value
mbstring.encoding_translation On Off
mbstring.func_overload 0 0

.htaccess:

php_value mbstring.func_overload 2
php_flag mbstring.encoding_translation On

Can you confirm or rebut this behavior?
Should we go to internals list?
Thanks,
Andre 



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



[PHP] Strange result, 1 shows up

2009-04-16 Thread Gary
When I insert this code into a page, I get a 1 show up. Can anyone explain 
that and tell me how to get rid of it?

Thanks for your help.

Gary

 



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



[PHP] Re: Strange result, 1 shows up

2009-04-16 Thread Jo�o C�ndido de Souza Neto
Try using only:  include('box.inc.php'); instead of  echo 
include('box.inc.php');


""Gary""  escreveu na mensagem 
news:63.c9.24434.0b377...@pb1.pair.com...
> When I insert this code into a page, I get a 1 show up. Can anyone explain 
> that and tell me how to get rid of it?
>
> Thanks for your help.
>
> Gary
>
>  //Chooses a random number
> $num = Rand (1,6);
> //Based on the random number, gives a quote
> switch ($num)
> {
> case 1:
> echo include('box.inc.php');
> break;
> case 2:
> echo "";
> break;
> case 3:
> echo "";
> break;
> case 4:
> echo "";
> break;
> case 5:
> echo "";
> break;
> case 6:
> echo "";
> }
> ?>
> 



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



[PHP] Re: Strange result, 1 shows up

2009-04-16 Thread Gary
Perfect, thanks so much.

Do you know why the number 1 displayed?

Thanks again.


""João Cândido de Souza Neto""  wrote in message 
news:9c.9a.24434.fc477...@pb1.pair.com...
> Try using only:  include('box.inc.php'); instead of  echo 
> include('box.inc.php');
>
>
> ""Gary""  escreveu na mensagem 
> news:63.c9.24434.0b377...@pb1.pair.com...
>> When I insert this code into a page, I get a 1 show up. Can anyone 
>> explain that and tell me how to get rid of it?
>>
>> Thanks for your help.
>>
>> Gary
>>
>> > //Chooses a random number
>> $num = Rand (1,6);
>> //Based on the random number, gives a quote
>> switch ($num)
>> {
>> case 1:
>> echo include('box.inc.php');
>> break;
>> case 2:
>> echo "";
>> break;
>> case 3:
>> echo "";
>> break;
>> case 4:
>> echo "";
>> break;
>> case 5:
>> echo "";
>> break;
>> case 6:
>> echo "";
>> }
>> ?>
>>
>
> 



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



RE: [PHP] Re: Strange result, 1 shows up

2009-04-16 Thread kyle.smith
You're echoing the return value of include(), which is "true", or 1. 


 
--
Kyle Smith
Unix Systems Administrator

-Original Message-
From: Gary [mailto:gwp...@ptd.net] 
Sent: Thursday, April 16, 2009 2:14 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Strange result, 1 shows up

Perfect, thanks so much.

Do you know why the number 1 displayed?

Thanks again.


""João Cândido de Souza Neto""  wrote in message 
news:9c.9a.24434.fc477...@pb1.pair.com...
> Try using only:  include('box.inc.php'); instead of  echo 
> include('box.inc.php');
>
>
> ""Gary""  escreveu na mensagem 
> news:63.c9.24434.0b377...@pb1.pair.com...
>> When I insert this code into a page, I get a 1 show up. Can anyone 
>> explain that and tell me how to get rid of it?
>>
>> Thanks for your help.
>>
>> Gary
>>
>> > //Chooses a random number
>> $num = Rand (1,6);
>> //Based on the random number, gives a quote switch ($num) { case 1:
>> echo include('box.inc.php');
>> break;
>> case 2:
>> echo "";
>> break;
>> case 3:
>> echo "";
>> break;
>> case 4:
>> echo "";
>> break;
>> case 5:
>> echo "";
>> break;
>> case 6:
>> echo "";
>> }
>> ?>
>>
>
> 



--
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] Re: Strange result, 1 shows up

2009-04-16 Thread Gary
Thank you for your help!

Gary


""kyle.smith""  wrote in message 
news:d3fe56d174abf6469079ca1a5c8474a804fa9...@nsmail01.inforonics.corp...
You're echoing the return value of include(), which is "true", or 1.



--
Kyle Smith
Unix Systems Administrator

-Original Message-
From: Gary [mailto:gwp...@ptd.net]
Sent: Thursday, April 16, 2009 2:14 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Strange result, 1 shows up

Perfect, thanks so much.

Do you know why the number 1 displayed?

Thanks again.


""João Cândido de Souza Neto""  wrote in message 
news:9c.9a.24434.fc477...@pb1.pair.com...
> Try using only:  include('box.inc.php'); instead of  echo
> include('box.inc.php');
>
>
> ""Gary""  escreveu na mensagem
> news:63.c9.24434.0b377...@pb1.pair.com...
>> When I insert this code into a page, I get a 1 show up. Can anyone
>> explain that and tell me how to get rid of it?
>>
>> Thanks for your help.
>>
>> Gary
>>
>> > //Chooses a random number
>> $num = Rand (1,6);
>> //Based on the random number, gives a quote switch ($num) { case 1:
>> echo include('box.inc.php');
>> break;
>> case 2:
>> echo "";
>> break;
>> case 3:
>> echo "";
>> break;
>> case 4:
>> echo "";
>> break;
>> case 5:
>> echo "";
>> break;
>> case 6:
>> echo "";
>> }
>> ?>
>>
>
>



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



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



[PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
Hi List,

I have been thinking for a while about setting up my own rapidshare.comclone,
Few days back I went really serious with this and came up with some ideas.

This is where I need your help, my partner and I have been thinking about
the
system that the website should run on.
We came to conclusion that we are going to write it in PHP.

There are several issues that came up during the mind-storm:
First, how we can keep the files out of being published as direct links?

My first idea was to host them one directory up from the http directory.
It seems good but how I would deliver the files to the users?
We are talking about unlimited file-size hosting so that means that we
will have to stream the files somehow... and they will be BIG (it's
defendant,
about 700MB~ each)

We thought of letting users pay by SMS'es, whats your ideas about it?

I'm generally looking after a "do" and "NOT do" list of creating a file
hoster ;)
If you have any general ideas / precautions that would definitely make my
partner and I happy :)

Thanks in Advance,
Nitsan


Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread haliphax
On Thu, Apr 16, 2009 at 1:29 PM, Nitsan Bin-Nun  wrote:
> Hi List,
>
> I have been thinking for a while about setting up my own rapidshare.comclone,
> Few days back I went really serious with this and came up with some ideas.
>
> This is where I need your help, my partner and I have been thinking about
> the
> system that the website should run on.
> We came to conclusion that we are going to write it in PHP.
>
> There are several issues that came up during the mind-storm:
> First, how we can keep the files out of being published as direct links?
>
> My first idea was to host them one directory up from the http directory.
> It seems good but how I would deliver the files to the users?
> We are talking about unlimited file-size hosting so that means that we
> will have to stream the files somehow... and they will be BIG (it's
> defendant,
> about 700MB~ each)
>
> We thought of letting users pay by SMS'es, whats your ideas about it?
>
> I'm generally looking after a "do" and "NOT do" list of creating a file
> hoster ;)
> If you have any general ideas / precautions that would definitely make my
> partner and I happy :)

With files of that size and the transfer speed of most broadband
users, you will almost absolutely have to use a Flash/Java uploader
app in order to ensure the files finish before server/browser timeout.

As far as hiding them from being accessed directly, I think you're
right--the file itself will have to be outside of your web root. I
would probably use a middle system to grab a request from your page,
verify that it did in fact come from your page (maybe with a
time-sensitive hash value) and then retrieve the file's contents based
on the validity of that hash value.

Just a thought.


-- 
// Todd

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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
What is Amazon SSS??

On Thu, Apr 16, 2009 at 8:59 PM, Leonard Burton wrote:

> Why not use something like Amazon SSS and not worry about a lot of the
> details?
>
> On Thu, Apr 16, 2009 at 2:29 PM, Nitsan Bin-Nun 
> wrote:
> > Hi List,
> >
> > I have been thinking for a while about setting up my own
> rapidshare.comclone,
> > Few days back I went really serious with this and came up with some
> ideas.
> >
> > This is where I need your help, my partner and I have been thinking about
> > the
> > system that the website should run on.
> > We came to conclusion that we are going to write it in PHP.
> >
> > There are several issues that came up during the mind-storm:
> > First, how we can keep the files out of being published as direct links?
> >
> > My first idea was to host them one directory up from the http directory.
> > It seems good but how I would deliver the files to the users?
> > We are talking about unlimited file-size hosting so that means that we
> > will have to stream the files somehow... and they will be BIG (it's
> > defendant,
> > about 700MB~ each)
> >
> > We thought of letting users pay by SMS'es, whats your ideas about it?
> >
> > I'm generally looking after a "do" and "NOT do" list of creating a file
> > hoster ;)
> > If you have any general ideas / precautions that would definitely make my
> > partner and I happy :)
> >
> > Thanks in Advance,
> > Nitsan
> >
>
>
>
> --
> Leonard Burton, N9URK
> http://www.jiffyslides.com
> serv...@jiffyslides.com
> leonardbur...@gmail.com
>
> "The prolonged evacuation would have dramatically affected the
> survivability of the occupants."
>


Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread 9el
Its Amazon S3 service. Which takes care of your CPU and scaling needs of
bandwidth. Good for CSS, JS and Image storing.


Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Leonard Burton
http://aws.amazon.com/s3/

On Thu, Apr 16, 2009 at 3:10 PM, Nitsan Bin-Nun  wrote:
> What is Amazon SSS??
>
> On Thu, Apr 16, 2009 at 8:59 PM, Leonard Burton 
> wrote:
>>
>> Why not use something like Amazon SSS and not worry about a lot of the
>> details?
>>
>> On Thu, Apr 16, 2009 at 2:29 PM, Nitsan Bin-Nun 
>> wrote:
>> > Hi List,
>> >
>> > I have been thinking for a while about setting up my own
>> > rapidshare.comclone,
>> > Few days back I went really serious with this and came up with some
>> > ideas.
>> >
>> > This is where I need your help, my partner and I have been thinking
>> > about
>> > the
>> > system that the website should run on.
>> > We came to conclusion that we are going to write it in PHP.
>> >
>> > There are several issues that came up during the mind-storm:
>> > First, how we can keep the files out of being published as direct links?
>> >
>> > My first idea was to host them one directory up from the http directory.
>> > It seems good but how I would deliver the files to the users?
>> > We are talking about unlimited file-size hosting so that means that we
>> > will have to stream the files somehow... and they will be BIG (it's
>> > defendant,
>> > about 700MB~ each)
>> >
>> > We thought of letting users pay by SMS'es, whats your ideas about it?
>> >
>> > I'm generally looking after a "do" and "NOT do" list of creating a file
>> > hoster ;)
>> > If you have any general ideas / precautions that would definitely make
>> > my
>> > partner and I happy :)
>> >
>> > Thanks in Advance,
>> > Nitsan
>> >
>>
>>
>>
>> --
>> Leonard Burton, N9URK
>> http://www.jiffyslides.com
>> serv...@jiffyslides.com
>> leonardbur...@gmail.com
>>
>> "The prolonged evacuation would have dramatically affected the
>> survivability of the occupants."
>
>



-- 
Leonard Burton, N9URK
http://www.jiffyslides.com
serv...@jiffyslides.com
leonardbur...@gmail.com

"The prolonged evacuation would have dramatically affected the
survivability of the occupants."

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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Nitsan Bin-Nun wrote:

Hi List,

I have been thinking for a while about setting up my own rapidshare.comclone,
Few days back I went really serious with this and came up with some ideas.

This is where I need your help, my partner and I have been thinking about
the
system that the website should run on.
We came to conclusion that we are going to write it in PHP.

There are several issues that came up during the mind-storm:
First, how we can keep the files out of being published as direct links?

My first idea was to host them one directory up from the http directory.
It seems good but how I would deliver the files to the users?


php wrapper.
It validates (session id or whatever) that the client has permission to 
access the file, and then sends the real file.


$archive = /path/to/some/tarball;
$tarname = "something.tar";

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);

header('Content-type: application/x-tar');
header("Content-Disposition: attachment; filename=" . $tarname);
header("Content-Transfer-Encoding: binary");
if ($fp = fopen( $archive , 'rb' )) {
   $sendOutput = "";
   while ($l = fgets($fp)) {
  $sendOutput .= $l;
  }
$outputLen = strlen($sendOutput);
header("Content-Length: $outputLen");
print $sendOutput;
} else {
// for whatever reason we failed
die();
}



We are talking about unlimited file-size hosting so that means that we
will have to stream the files somehow... and they will be BIG (it's
defendant,
about 700MB~ each)


Then I suggest setting up a torrent instead of direct download.
You can have protected torrents. I don't know how to set them up but I 
use them - there's a torrent site that requires I log in from the same 
IP as I'm running the torrent client from, for example.


If you want to provide service for those who can not use a torrent 
client, use an ftp server to serve the files - so that ftp clients 
capable of continuing an interrupted download can be used.


700MB is really too big fot http. Sure, it works, but it is better to 
use a protocol designed for large binary files.


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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Michael A. Peters wrote:



$archive = /path/to/some/tarball;


should be $archive = '/path/to/some/tarball';

:D

rest of the code is copied from a file I use to serve content that is 
outside the web root.


That's one of my rules - the web server never has write permission to 
any directory inside the web root (I don't want a server bug to allow a 
cracker to trick the server into writing a file it then directly serves).


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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
My bad, I'm sending a copy to the list.

On Thu, Apr 16, 2009 at 9:37 PM, Nitsan Bin-Nun  wrote:

> Actually I don't much care for that, IMO 700MB~ is way too big for HTTP, I
> thought of giving away FTP links for download, but I have thought of the
> following:
> * First, there is a solution which will do this session validation/etc
> through .htaccess and will only rewrite it to the file instead of sending it
> in chunks? because that if the server will have to send it in chunks it will
> be a no-reason overkill for the CPU (calculating and reading these
> files. overkill).
> * Secondly, I thought of sending these 700MB~ through HTTP and giving away
> FTP links for the people who bought this functionality, I don't really care
> whether it works or not, as long as the website reputation is still up.
>
> I also have just signed a contract with downloads website which has 80k
> unique visitors/DAY!
> So I really have to think of scalability from the beginning of it,
> Do you have any ideas/notes/anything that I should take care of or keep in
> calculations when thinking of 80k crowd driving full speed on towards my
> server every DAY??
>
> Thanks in Advance,
> Nitsan
>
>
> On Thu, Apr 16, 2009 at 9:27 PM, Michael A. Peters wrote:
>
>> Nitsan Bin-Nun wrote:
>>
>>> Hi List,
>>>
>>> I have been thinking for a while about setting up my own
>>> rapidshare.comclone,
>>> Few days back I went really serious with this and came up with some
>>> ideas.
>>>
>>> This is where I need your help, my partner and I have been thinking about
>>> the
>>> system that the website should run on.
>>> We came to conclusion that we are going to write it in PHP.
>>>
>>> There are several issues that came up during the mind-storm:
>>> First, how we can keep the files out of being published as direct links?
>>>
>>> My first idea was to host them one directory up from the http directory.
>>> It seems good but how I would deliver the files to the users?
>>>
>>
>> php wrapper.
>> It validates (session id or whatever) that the client has permission to
>> access the file, and then sends the real file.
>>
>> $archive = /path/to/some/tarball;
>> $tarname = "something.tar";
>>
>> header("Pragma: public");
>> header("Expires: 0");
>> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
>> header("Cache-Control: private",false);
>>
>> header('Content-type: application/x-tar');
>> header("Content-Disposition: attachment; filename=" . $tarname);
>> header("Content-Transfer-Encoding: binary");
>> if ($fp = fopen( $archive , 'rb' )) {
>>   $sendOutput = "";
>>   while ($l = fgets($fp)) {
>>  $sendOutput .= $l;
>>  }
>>$outputLen = strlen($sendOutput);
>>header("Content-Length: $outputLen");
>>print $sendOutput;
>>} else {
>>// for whatever reason we failed
>>die();
>>}
>>
>>
>>  We are talking about unlimited file-size hosting so that means that we
>>> will have to stream the files somehow... and they will be BIG (it's
>>> defendant,
>>> about 700MB~ each)
>>>
>>
>> Then I suggest setting up a torrent instead of direct download.
>> You can have protected torrents. I don't know how to set them up but I use
>> them - there's a torrent site that requires I log in from the same IP as I'm
>> running the torrent client from, for example.
>>
>> If you want to provide service for those who can not use a torrent client,
>> use an ftp server to serve the files - so that ftp clients capable of
>> continuing an interrupted download can be used.
>>
>> 700MB is really too big fot http. Sure, it works, but it is better to use
>> a protocol designed for large binary files.
>>
>
>


RE: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread kyle.smith
How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
benchmark FTP vs HTTP, the overhead is minimal... 


 
--
Kyle Smith
Unix Systems Administrator

-Original Message-
From: Nitsan Bin-Nun [mailto:nit...@binnun.co.il] 
Sent: Thursday, April 16, 2009 3:37 PM
To: PHP General List
Subject: Re: [PHP] Need Your Help :) I'm Just About Creating File
Uploading Service

My bad, I'm sending a copy to the list.

On Thu, Apr 16, 2009 at 9:37 PM, Nitsan Bin-Nun 
wrote:

> Actually I don't much care for that, IMO 700MB~ is way too big for 
> HTTP, I thought of giving away FTP links for download, but I have 
> thought of the
> following:
> * First, there is a solution which will do this session validation/etc

> through .htaccess and will only rewrite it to the file instead of 
> sending it in chunks? because that if the server will have to send it 
> in chunks it will be a no-reason overkill for the CPU (calculating and

> reading these files. overkill).
> * Secondly, I thought of sending these 700MB~ through HTTP and giving 
> away FTP links for the people who bought this functionality, I don't 
> really care whether it works or not, as long as the website reputation
is still up.
>
> I also have just signed a contract with downloads website which has 
> 80k unique visitors/DAY!
> So I really have to think of scalability from the beginning of it, Do 
> you have any ideas/notes/anything that I should take care of or keep 
> in calculations when thinking of 80k crowd driving full speed on 
> towards my server every DAY??
>
> Thanks in Advance,
> Nitsan
>
>
> On Thu, Apr 16, 2009 at 9:27 PM, Michael A. Peters
wrote:
>
>> Nitsan Bin-Nun wrote:
>>
>>> Hi List,
>>>
>>> I have been thinking for a while about setting up my own 
>>> rapidshare.comclone, Few days back I went really serious with this 
>>> and came up with some ideas.
>>>
>>> This is where I need your help, my partner and I have been thinking 
>>> about the system that the website should run on.
>>> We came to conclusion that we are going to write it in PHP.
>>>
>>> There are several issues that came up during the mind-storm:
>>> First, how we can keep the files out of being published as direct
links?
>>>
>>> My first idea was to host them one directory up from the http
directory.
>>> It seems good but how I would deliver the files to the users?
>>>
>>
>> php wrapper.
>> It validates (session id or whatever) that the client has permission 
>> to access the file, and then sends the real file.
>>
>> $archive = /path/to/some/tarball;
>> $tarname = "something.tar";
>>
>> header("Pragma: public");
>> header("Expires: 0");
>> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
>> header("Cache-Control: private",false);
>>
>> header('Content-type: application/x-tar');
>> header("Content-Disposition: attachment; filename=" . $tarname);
>> header("Content-Transfer-Encoding: binary"); if ($fp = fopen( 
>> $archive , 'rb' )) {
>>   $sendOutput = "";
>>   while ($l = fgets($fp)) {
>>  $sendOutput .= $l;
>>  }
>>$outputLen = strlen($sendOutput);
>>header("Content-Length: $outputLen");
>>print $sendOutput;
>>} else {
>>// for whatever reason we failed
>>die();
>>}
>>
>>
>>  We are talking about unlimited file-size hosting so that means that 
>> we
>>> will have to stream the files somehow... and they will be BIG (it's 
>>> defendant, about 700MB~ each)
>>>
>>
>> Then I suggest setting up a torrent instead of direct download.
>> You can have protected torrents. I don't know how to set them up but
I use
>> them - there's a torrent site that requires I log in from the same IP
as I'm
>> running the torrent client from, for example.
>>
>> If you want to provide service for those who can not use a torrent
client,
>> use an ftp server to serve the files - so that ftp clients capable of
>> continuing an interrupted download can be used.
>>
>> 700MB is really too big fot http. Sure, it works, but it is better to
use
>> a protocol designed for large binary files.
>>
>
>

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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Paul M Foster
On Thu, Apr 16, 2009 at 12:27:38PM -0700, Michael A. Peters wrote:



>> We are talking about unlimited file-size hosting so that means that we
>> will have to stream the files somehow... and they will be BIG (it's
>> defendant,
>> about 700MB~ each)
>
> Then I suggest setting up a torrent instead of direct download.
> You can have protected torrents. I don't know how to set them up but I
> use them - there's a torrent site that requires I log in from the same
> IP as I'm running the torrent client from, for example.

A torrent is only fast or faster because you can get various pieces of
the file from various peers or servers on the internet, simultaneously.
I don't expect that people uploading their private photos of their
girlfriends want them shared in any way, except with the eventual
recipient.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

kyle.smith wrote:

How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
benchmark FTP vs HTTP, the overhead is minimal... 


I download linux distro's all the time - er, whenever a new CentOS is 
released.


It's not overhead that is the issue.
It's being able to continue an interrupted download that is an issue.

Some http clients may be able to, though I suspect that would require a 
non standard extension to http that both client and server understand.


Also - many people use a temp filesystem (aka ram disk) for www 
downloads (I doubt a majority but those of us who are smart) - where the 
file is initially put until all the pieces have come down before it is 
finally saved to the destination. Using tempfs for that requires less 
disk IO because your www downloads are typically small, so no need to 
write to disk until you have it all when it can do the write at once.


700MB can easily fill that temp filesystem, depending upon the size of 
your tempfs (and what else it is being used for).


Serving via ftp - virtually every ftp client out there knows how to 
resume an interrupted download, so it is much better suited for large 
downloads than http. And serving via ftp/torrent - the user is far less 
likely to be using a tempfs as a staging area that can result in a bad 
download.


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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Paul M Foster wrote:


Then I suggest setting up a torrent instead of direct download.
You can have protected torrents. I don't know how to set them up but I
use them - there's a torrent site that requires I log in from the same
IP as I'm running the torrent client from, for example.


A torrent is only fast or faster because you can get various pieces of
the file from various peers or servers on the internet, simultaneously.
I don't expect that people uploading their private photos of their
girlfriends want them shared in any way, except with the eventual
recipient.

Paul



The point of torrent isn't speed - but because torrent is excellent at 
dealing with interruption in network before the download is complete, 
and far less likely to result in a bad download.


In fact - I've used torrent to fix files that were improperly downloaded 
without having to download them again.


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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Ashley Sheridan
On Thu, 2009-04-16 at 13:31 -0700, Michael A. Peters wrote:
> Paul M Foster wrote:
> 
> >> Then I suggest setting up a torrent instead of direct download.
> >> You can have protected torrents. I don't know how to set them up but I
> >> use them - there's a torrent site that requires I log in from the same
> >> IP as I'm running the torrent client from, for example.
> > 
> > A torrent is only fast or faster because you can get various pieces of
> > the file from various peers or servers on the internet, simultaneously.
> > I don't expect that people uploading their private photos of their
> > girlfriends want them shared in any way, except with the eventual
> > recipient.
> > 
> > Paul
> > 
> 
> The point of torrent isn't speed - but because torrent is excellent at 
> dealing with interruption in network before the download is complete, 
> and far less likely to result in a bad download.
> 
> In fact - I've used torrent to fix files that were improperly downloaded 
> without having to download them again.
> 
But a torrent in this case is entirely unsuitable as the op said. As far
as I'm aware, HTTP is fine for downloads, and it's served me fine using
it, but uploads are a different matter. Using FTP for both would
certainly solve a lot of issues however.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
You are definitely right, but there is one thing that you didn't knew and
I'm sure that you didn't take into account - usually the files on the server
will be DVD rip's that are typically 700MB~ in size, every second movie that
people will download will contain some interrupted pieces, although that
these small pieces won't affect the file that much in order to keep it out
from playing. Most of the video players know how to player these corrupted
files and will handle them good.

And for torrent - this is a good solution but this is not what I'm after,
I'm going to set up an HTTP file hoster, not a torrent tracker ;)

Any other ideas regarding serving the files and hosting them will be very
appreciated!!

Thank you guys for all the ongoing help in this list ;)

Kind Regards,
Nitsan

On Thu, Apr 16, 2009 at 10:29 PM, Michael A. Peters  wrote:

> kyle.smith wrote:
>
>> How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
>> benchmark FTP vs HTTP, the overhead is minimal...
>>
>
> I download linux distro's all the time - er, whenever a new CentOS is
> released.
>
> It's not overhead that is the issue.
> It's being able to continue an interrupted download that is an issue.
>
> Some http clients may be able to, though I suspect that would require a non
> standard extension to http that both client and server understand.
>
> Also - many people use a temp filesystem (aka ram disk) for www downloads
> (I doubt a majority but those of us who are smart) - where the file is
> initially put until all the pieces have come down before it is finally saved
> to the destination. Using tempfs for that requires less disk IO because your
> www downloads are typically small, so no need to write to disk until you
> have it all when it can do the write at once.
>
> 700MB can easily fill that temp filesystem, depending upon the size of your
> tempfs (and what else it is being used for).
>
> Serving via ftp - virtually every ftp client out there knows how to resume
> an interrupted download, so it is much better suited for large downloads
> than http. And serving via ftp/torrent - the user is far less likely to be
> using a tempfs as a staging area that can result in a bad download.
>


Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Michael A. Peters wrote:

kyle.smith wrote:

How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
benchmark FTP vs HTTP, the overhead is minimal... 


I download linux distro's all the time - er, whenever a new CentOS is 
released.


It's not overhead that is the issue.
It's being able to continue an interrupted download that is an issue.


Resuming interrupted downloads when you are using php to serve a file 
not in the document root is probably even trickier.


If you don't mind your server doing that, then go ahead and use http - 
but it will result in increased bandwidth from browsers that crashed, 
network hickups, etc.


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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
Neh, we don't have plenty of these in Israel, don't count it in as an issue.

Serving the files won't be an overkill for my harddrive / cpu usage /
anything else?

There is a better way to serve the files with/without PHP and keeping them
outsite of the HTTP root?

Thanks in Advance,
Nitsan

On Thu, Apr 16, 2009 at 10:43 PM, Michael A. Peters  wrote:

> Michael A. Peters wrote:
>
>> kyle.smith wrote:
>>
>>> How is 700MB too big for HTTP?  Ever download a linux distro?  Ever
>>> benchmark FTP vs HTTP, the overhead is minimal...
>>>
>>
>> I download linux distro's all the time - er, whenever a new CentOS is
>> released.
>>
>> It's not overhead that is the issue.
>> It's being able to continue an interrupted download that is an issue.
>>
>
> Resuming interrupted downloads when you are using php to serve a file not
> in the document root is probably even trickier.
>
> If you don't mind your server doing that, then go ahead and use http - but
> it will result in increased bandwidth from browsers that crashed, network
> hickups, etc.
>


Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Nitsan Bin-Nun wrote:

Neh, we don't have plenty of these in Israel, don't count it in as an issue.

Serving the files won't be an overkill for my harddrive / cpu usage /
anything else?

There is a better way to serve the files with/without PHP and keeping them
outsite of the HTTP root?


If you want to use http the code I provided in my first response works 
very well for files I serve outside the web root.


make a dummy directory in the web root.
In that dummy directory put a single php file - called "dummy.php" or 
whatever.


Have that file check the users credentials etc. (IE via session id) - 
and have


$thispage=$_SERVER['REQUEST_URI'];

put a .htaccess file in the dummy directory containing:

RewriteEngine on
RewriteRule ^*\.iso$ dummy.php

That way a request to /dummy/something.iso

is handled by dummy.php - which then can figure out what file is wanted 
via the $thispage variable, verify the user has permission to download 
it via sessions etc. (and sends a 403 header if they don't), verifies 
that the file exists (and sends a 404 header if it doesn't), and then 
uses the code I outlined in my first post to grab the file from the real 
location that is outside the web root and sends it to the requesting client.


It works quite well for me.

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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Michael A. Peters wrote:

Nitsan Bin-Nun wrote:
Neh, we don't have plenty of these in Israel, don't count it in as an 
issue.


Serving the files won't be an overkill for my harddrive / cpu usage /
anything else?

There is a better way to serve the files with/without PHP and keeping 
them

outsite of the HTTP root?


If you want to use http the code I provided in my first response works 
very well for files I serve outside the web root.


make a dummy directory in the web root.
In that dummy directory put a single php file - called "dummy.php" or 
whatever.


Have that file check the users credentials etc. (IE via session id) - 
and have


$thispage=$_SERVER['REQUEST_URI'];

put a .htaccess file in the dummy directory containing:

RewriteEngine on
RewriteRule ^*\.iso$ dummy.php


That assumes apache is your server, you have the mod_rewrite module, and 
allow .htaccess override (if you don't want to allow .htaccess overide 
you can put the rewrite directive right in the http.conf for the dummy 
directory)


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



Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Nitsan Bin-Nun
It's really simple and I wrote several of these long time before, but I
thought that there might be an option of serving the files w/o using PHP to
read it and send the headers and chunks using only htaccess for the serving
and PHP for the validation of the session.

On Thu, Apr 16, 2009 at 10:58 PM, Michael A. Peters  wrote:

> Nitsan Bin-Nun wrote:
>
>> Neh, we don't have plenty of these in Israel, don't count it in as an
>> issue.
>>
>> Serving the files won't be an overkill for my harddrive / cpu usage /
>> anything else?
>>
>> There is a better way to serve the files with/without PHP and keeping them
>> outsite of the HTTP root?
>>
>
> If you want to use http the code I provided in my first response works very
> well for files I serve outside the web root.
>
> make a dummy directory in the web root.
> In that dummy directory put a single php file - called "dummy.php" or
> whatever.
>
> Have that file check the users credentials etc. (IE via session id) - and
> have
>
> $thispage=$_SERVER['REQUEST_URI'];
>
> put a .htaccess file in the dummy directory containing:
>
> RewriteEngine on
> RewriteRule ^*\.iso$ dummy.php
>
> That way a request to /dummy/something.iso
>
> is handled by dummy.php - which then can figure out what file is wanted via
> the $thispage variable, verify the user has permission to download it via
> sessions etc. (and sends a 403 header if they don't), verifies that the file
> exists (and sends a 404 header if it doesn't), and then uses the code I
> outlined in my first post to grab the file from the real location that is
> outside the web root and sends it to the requesting client.
>
> It works quite well for me.
>


Re: [PHP] Need Your Help :) I'm Just About Creating File Uploading Service

2009-04-16 Thread Michael A. Peters

Nitsan Bin-Nun wrote:

It's really simple and I wrote several of these long time before, but I
thought that there might be an option of serving the files w/o using PHP to
read it and send the headers and chunks using only htaccess for the serving
and PHP for the validation of the session.


There might be - I'm not familiar with such a technique though.
You may be able to use php sessions to enter an IP into a database (or 
flat file) that standard apache access restrictions could use to 
determine whether or not to send the file.


IE upon succesful login from 192.168.15.7 - that IP is added to a list 
used in an apache "allow from" directive.


The potential problem I see with that is the IP address you associate 
with a session may be a proxy.


But there may be solutions to that.

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



[PHP] cURL Download

2009-04-16 Thread Robbert van Andel
I've been struggling to download a file from a network file share using
cURL, or whatever else will work.   All I want to do is get the contents of
a text file.  But when I run the code below I get this error "Error: 37 -
Couldn't open file \\server\share\test.txt".  I'm running my website on a
linux box, but the server is on a Windows file server.  I've verified that
the file share works when I use Windows Explorer and that the server can get
the file via the command line using smbclient.  Any help would be
appreciated.

Getting $file\n";

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_HEADER, false);

// grab file and pass it to the browser
echo "File: " . curl_exec($ch) ."\n";
echo "Error: " . curl_errno($ch) . " - " . curl_error($ch) .
"\n";
?>

Thanks,
Robbert


[PHP] array manipulation

2009-04-16 Thread PJ
The more I get into arrays, the less I understand.
I have a ridiculously simple task which excapes me completely.
I need to ouput all fields in 1 column from 1 table in two phases sorted
alphabetically.
So, I have the query, I have the results. But since I need to split the
list into 2 parts, I need indexes. I cannot use the table index as it
does not correspond to the alphabetical order of the data column. In
order to get the index, I sort the resulting array and that now gives me
34 arrays each containing an array of my results. Wonderful!
But how do I now extract the arrays from the array?

Here is what I'm trying to do:

$SQL = "SELECT category
FROM categories
ORDER BY category ASC
";
$category = array();
if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
while ( $row = mysql_fetch_assoc($results) ) {
$category[$row['category']] = $row;
}
sort($category);
//var_dump($category);
echo "";
$count = mysql_num_rows($results);
$lastIndex = $count/2 -1; echo $lastIndex;
$ii = 0;
$cat = '';
//print_r($category['0']['category']);
foreach($category as $index => $value) {
$ii++;
if ($ii != $lastIndex) {
$cat .= "$value, ";
}
else {
$cat .= " & $value";
}
$catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat);
//echo "$category";
echo "
", $cat, "

" ;
}
}
echo "";

What should I be using in the foreach line?
Please help!

-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] redirect to a page the fist time a site is accessed

2009-04-16 Thread Clancy
On Thu, 16 Apr 2009 09:26:52 -0500, nos...@mckenzies.net (Shawn McKenzie) wrote:

>Stuart wrote:
>> 2009/4/15 Don :
>>> I have some code in my index.php file that check the user agent and
>>> redirects to a warning page if IE 6 or less is encountered.
>>>
>>> 1. I'm using a framework and so calls to all pages go through index.php
>>> 2. The code that checks for IE 6 or less and redirects is in index.php
>>>
>>> I know how to redirect the users but what I want to do is redirect a user
>>> ONLY the first time the web site is accessed regardless of what page they
>>> first access.  I would like to minimize overhead (no database).  Can this be
>>> done?
>> 
>> Why redirect? That sucks as a user experience. Why not simply put an
>> alert somewhere prominent on the page with the message you want to
>> convey? That way you can have it on every page and not interrupt the
>> users use of your site.
>
>I agree, and you can still try the cookie method to not show the
>message, but it's not a big deal if they don't get the cookie/it expires
>etc., because the worst thing that can happen is that they see the message.

Alternatively add a link 'If you are new/Introduction/etc' that the new user 
can click to
get more information if they want it.


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



Re: [PHP] array manipulation

2009-04-16 Thread PJ
Sorry, bout that.
My brain wasn't working right.
It was a lot simpler than I thought. Forget the foreach.
I used a counter. :-[

PJ wrote:
> The more I get into arrays, the less I understand.
> I have a ridiculously simple task which excapes me completely.
> I need to ouput all fields in 1 column from 1 table in two phases sorted
> alphabetically.
> So, I have the query, I have the results. But since I need to split the
> list into 2 parts, I need indexes. I cannot use the table index as it
> does not correspond to the alphabetical order of the data column. In
> order to get the index, I sort the resulting array and that now gives me
> 34 arrays each containing an array of my results. Wonderful!
> But how do I now extract the arrays from the array?
>
> Here is what I'm trying to do:
>
> $SQL = "SELECT category
> FROM categories
> ORDER BY category ASC
> ";
> $category = array();
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
> while ( $row = mysql_fetch_assoc($results) ) {
> $category[$row['category']] = $row;
> }
> sort($category);
> //var_dump($category);
> echo "";
> $count = mysql_num_rows($results);
> $lastIndex = $count/2 -1; echo $lastIndex;
> $ii = 0;
> $cat = '';
> //print_r($category['0']['category']);
> foreach($category as $index => $value) {
> $ii++;
> if ($ii != $lastIndex) {
> $cat .= "$value, ";
> }
> else {
> $cat .= " & $value";
> }
> $catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat);
> //echo "$category";
> echo "
> ", $cat, "
> 
> " ;
> }
> }
> echo "";
>
> What should I be using in the foreach line?
> Please help!
>
>   


-- 
unheralded genius: "A clean desk is the sign of a dull mind. "
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



[PHP] catching up

2009-04-16 Thread Tim | iHostNZ
Hey guys,

Just trying to catch up to the rest of the world again. Prob wont be able to
read all the php mail.

Just one thing: Maybe PHP should be renamed to PFP (PHP Free Processor) or
something. A recursive acronym sort of suggests that you cannot be free or
break out of this infinite loop. What do you think? It could introduce
another variable call it $f (for FREE of course, nothing else you dirty
minded people), you get the idea.

Btw donations on my website are not abused, but rediculously low. I was
planning to make my CSV to SQL program free software, but without donations
im afraid ill have to fight a court case with the guy who owns me.

i love diet coke or coke zero is even better. advertisement not intended.

Cheers,
Tim
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn
- "A wide screen just makes a bad film twice as bad."


[PHP] Fwd: catching up

2009-04-16 Thread German Geek
just in case/tim(e). Yes its me :)
Tim-Hinnerk Heuer

http://www.ihostnz.com
Mitch Hedberg
- "I drank some boiling water because I wanted to whistle."

-- Forwarded message --
From: Tim | iHostNZ 
Date: 2009/4/17
Subject: catching up
To: PHP General list 


Hey guys,

Just trying to catch up to the rest of the world again. Prob wont be able to
read all the php mail.

Just one thing: Maybe PHP should be renamed to PFP (PHP Free Processor) or
something. A recursive acronym sort of suggests that you cannot be free or
break out of this infinite loop. What do you think? It could introduce
another variable call it $f (for FREE of course, nothing else you dirty
minded people), you get the idea.

Btw donations on my website are not abused, but rediculously low. I was
planning to make my CSV to SQL program free software, but without donations
im afraid ill have to fight a court case with the guy who owns me.

i love diet coke or coke zero is even better. advertisement not intended.

Cheers,
Tim
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn
- "A wide screen just makes a bad film twice as bad."


Re: [PHP] array manipulation

2009-04-16 Thread German Geek
soln: YOU NEED A 2 WEEK HOLLIDAY at least! You need to learn to say no.
Tim-Hinnerk Heuer

http://www.ihostnz.com
Samuel Goldwyn
- "A wide screen just makes a bad film twice as bad."

2009/4/17 PJ 

> The more I get into arrays, the less I understand.
> I have a ridiculously simple task which excapes me completely.
> I need to ouput all fields in 1 column from 1 table in two phases sorted
> alphabetically.
> So, I have the query, I have the results. But since I need to split the
> list into 2 parts, I need indexes. I cannot use the table index as it
> does not correspond to the alphabetical order of the data column. In
> order to get the index, I sort the resulting array and that now gives me
> 34 arrays each containing an array of my results. Wonderful!
> But how do I now extract the arrays from the array?
>
> Here is what I'm trying to do:
>
> $SQL = "SELECT category
>FROM categories
>ORDER BY category ASC
>";
> $category = array();
> if ( ( $results = mysql_query($SQL, $db) ) !== false ) {
>while ( $row = mysql_fetch_assoc($results) ) {
>$category[$row['category']] = $row;
>}
>sort($category);
>//var_dump($category);
>echo "";
>$count = mysql_num_rows($results);
>$lastIndex = $count/2 -1; echo $lastIndex;
>$ii = 0;
>$cat = '';
> //print_r($category['0']['category']);
>foreach($category as $index => $value) {
>$ii++;
>if ($ii != $lastIndex) {
>$cat .= "$value, ";
>}
>else {
>$cat .= " & $value";
>}
>$catn = preg_replace("/[^a-zA-Z0-9]/", "", $cat);
>//echo "$category";
>echo "
>", $cat, "
>
>" ;
>}
> }
> echo "";
>
> What should I be using in the foreach line?
> Please help!
>
> --
> unheralded genius: "A clean desk is the sign of a dull mind. "
> -
> Phil Jourdan --- p...@ptahhotep.com
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] pup

2009-04-16 Thread ramesh.marimuthu
Hi,

I'm new to this list. Can I post PUP questions to this list?

regards,
-ramesh

P Save a tree...please don't print this e-mail unless you really need to


Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com


Re: [PHP] pup

2009-04-16 Thread German Geek
>From What i learned, yes you can write pup here. Does anyone print this
mailing list? wtf?? i keep overestimating people's intelligence, im sorry!
Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles de 
Gaulle
- "The better I get to know men, the more I find myself loving dogs."

2009/4/17 

> Hi,
>
> I'm new to this list. Can I post PUP questions to this list?
>
> regards,
> -ramesh
>
> P Save a tree...please don't print this e-mail unless you really need to
>
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to
> this message are intended for the exclusive use of the addressee(s) and may
> contain proprietary, confidential or privileged information. If you are not
> the intended recipient, you should not disseminate, distribute or copy this
> e-mail. Please notify the sender immediately and destroy all copies of this
> message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses. The
> company accepts no liability for any damage caused by any virus transmitted
> by this email.
>
> www.wipro.com
>


RE: [PHP] pup

2009-04-16 Thread ramesh.marimuthu

Hi,

I'm new to php.
Say I have a check box which is checked already. Now I need to uncheck
it and when I press the submit button, I should get the unchecked value.
Can anyone help me on this.

One.php

if($qry[0]!=$login_type)
{
echo "".$slot_value."";
}
else
{
echo "".$slot_value."";
}

One.php calls Two.php
Two.php

$enable_slot= $_POST['enable'];
$uncheck_slot= $_POST['uncheck'];

if ($enable_slot){
echo "$enable_slot";
foreach($enable_slot as &$a) {
echo "".$a." --unreserve";
}
}

I get only the results only if checked. I think I'm doing a mistake in
the code in red font.

regards,
-rummy




From: th.he...@gmail.com [mailto:th.he...@gmail.com] On Behalf Of German
Geek
Sent: Friday, April 17, 2009 9:47 AM
To: Ramesh Marimuthu (WT01 - Telecom Equipment)
Cc: php-general@lists.php.net
Subject: Re: [PHP] pup


>From What i learned, yes you can write pup here. Does anyone print this
mailing list? wtf?? i keep overestimating people's intelligence, im
sorry!
Tim-Hinnerk Heuer

http://www.ihostnz.com
Charles de Gaulle
   -
"The better I get to know men, the more I find myself loving dogs."


2009/4/17 


Hi,

I'm new to this list. Can I post PUP questions to this list?

regards,
-ramesh

P Save a tree...please don't print this e-mail unless you really
need to


Please do not print this email unless it is absolutely
necessary.

The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
addressee(s) and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The
recipient should check this email and any attachments for the presence
of viruses. The company accepts no liability for any damage caused by
any virus transmitted by this email.

www.wipro.com




Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com


Re: [PHP] cURL - Error 400

2009-04-16 Thread David
Hi,

Sorry, that didn't work. The website is still returning error 400 with
CURLOPT_COOKIESESSION and CURLOPT_COOKIE enabled.

I did some experimentation in Firefox by blocking and deleting all cookies
from the site. When I then visited the site, I was able to reach the logon
page without returning error 400 so I doubt it's cookies that is the
problem.

I also tried changing the HTTP headers to:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

Which didn't work either.




Thanks

On Thu, Apr 16, 2009 at 11:48 PM, haliphax  wrote:

> On Wed, Apr 15, 2009 at 9:17 PM, David  wrote:
> > Except I also need to POST data to the server to login. After I've logged
> > in, I then need to use cookies to maintain a session.
> >
> > Doing that via file_get_contents() just isn't possible.
> >
> >
> > Thanks
> >
> > On Thu, Apr 16, 2009 at 2:30 AM, haliphax  wrote:
> >>
> >> On Wed, Apr 15, 2009 at 10:36 AM, David 
> wrote:
> >> > I was wondering if anyone could please help me with this cURL script
> >> > since I
> >> > keep getting error 400 from the web server:
> >> >
> >> > http://pastebin.ca/1392840
> >> >
> >> > It worked until around a month ago which is when they presumably made
> >> > changes to the site. Except I can't figure out what configuration
> option
> >> > in
> >> > the cURL PHP script needs to be changed. I can visit the site
> perfectly
> >> > in
> >> > Lynx, Firefox and IE.
> >>
> >> Are you just trying to get the contents of the page, or is there
> >> something special you're doing? If it's just the contents you're
> >> after, try file_get_contents() if allow_url_fopen is set to TRUE for
> >> your PHP installation.
> >>
> >> http://php.net/file_get_contents
> >> http://php.net/allow_url_fopen
>
> David, please refrain from top-posting.
>
> As for cURL login/session handling... I have an automated script that
> connects to a phpBB bulletin board, and here are the settings that
> have worked for me:
>
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($ch, CURLOPT_COOKIESESSION, true);
> curl_setopt($ch, CURLOPT_HEADER, false);
> curl_setopt($ch, CURLOPT_COOKIEFILE, "{$homedir}cookiefile");
> curl_setopt($ch, CURLOPT_COOKIEJAR, "{$homedir}cookiefile");
> curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
>
> I would think CURLOPT_FOLLOWLOCATION and the CURLOPT_COOKIE* options
> are most important for resolving your issue.
>
> HTH,
>
>
> --
> // Todd
>


Re: [PHP] pup

2009-04-16 Thread Jim Lucas

ramesh.marimu...@wipro.com wrote:
 
Hi,
 
I'm new to php.

Say I have a check box which is checked already. Now I need to uncheck
it and when I press the submit button, I should get the unchecked value.
Can anyone help me on this.

One.php

if($qry[0]!=$login_type)
{
echo "".$slot_value."";
}
else
{
echo "
".$slot_value."";

}

One.php calls Two.php
Two.php

$enable_slot= $_POST['enable'];
$uncheck_slot= $_POST['uncheck'];

if ($enable_slot){
echo "$enable_slot";
foreach($enable_slot as &$a) {
echo "".$a." --unreserve";
}
}

I get only the results only if checked. I think I'm doing a mistake in
the code in red font.

regards,
-rummy

 


When you uncheck a checkbox in an HTML form, it will not be submitted.

http://www.w3.org/TR/html401/interact/forms.html#checkbox

The part on the above page talking about "only "on" checkbox controls can become 
successful." is the key here.

The successful part links here:

http://www.w3.org/TR/html401/interact/forms.html#successful-controls

This explains that the definition of a successful checkbox submission is one that is  
"on".
To have a checkbox in the "on" state means that it has to be checked.

So, any checkbox that is /not/ checked is considered "off" or "undefined" will 
not be submitted because it is not valid.

Or something like that... :)

Jim Lucas

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



RE: [PHP] pup

2009-04-16 Thread ramesh.marimuthu

Thanks Jim. Is there a way to get the value of that unchecked box?

-rummy

-Original Message-
From: Jim Lucas [mailto:li...@cmsws.com]
Sent: Friday, April 17, 2009 10:35 AM
To: Ramesh Marimuthu (WT01 - Telecom Equipment)
Cc: geek...@gmail.com; php-general@lists.php.net
Subject: Re: [PHP] pup

ramesh.marimu...@wipro.com wrote:
>
> Hi,
>
> I'm new to php.
> Say I have a check box which is checked already. Now I need to uncheck

> it and when I press the submit button, I should get the unchecked
value.
> Can anyone help me on this.
>
> One.php
>
> if($qry[0]!=$login_type)
> {
> echo " style=background-color:#CC66CC> value=a".$count." checked DISABLED />".$slot_value.""; }
> else { echo " style=background-color:#00> value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."'
> checked
>> ".$slot_value."";
> }
>
> One.php calls Two.php
> Two.php
>
> $enable_slot= $_POST['enable'];
> $uncheck_slot= $_POST['uncheck'];
>
> if ($enable_slot){
> echo "$enable_slot";
> foreach($enable_slot as &$a) {
> echo "".$a." --unreserve";
> }
> }
>
> I get only the results only if checked. I think I'm doing a mistake in

> the code in red font.
>
> regards,
> -rummy
>
>

When you uncheck a checkbox in an HTML form, it will not be submitted.

http://www.w3.org/TR/html401/interact/forms.html#checkbox

The part on the above page talking about "only "on" checkbox controls
can become successful." is the key here.

The successful part links here:

http://www.w3.org/TR/html401/interact/forms.html#successful-controls

This explains that the definition of a successful checkbox submission is
one that is  "on".
To have a checkbox in the "on" state means that it has to be checked.

So, any checkbox that is /not/ checked is considered "off" or
"undefined" will not be submitted because it is not valid.

Or something like that... :)

Jim Lucas

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

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



Re: [PHP] pup

2009-04-16 Thread Jim Lucas

ramesh.marimu...@wipro.com wrote:
Thanks Jim. Is there a way to get the value of that unchecked box? 


-rummy

-Original Message-
From: Jim Lucas [mailto:li...@cmsws.com] 
Sent: Friday, April 17, 2009 10:35 AM

To: Ramesh Marimuthu (WT01 - Telecom Equipment)
Cc: geek...@gmail.com; php-general@lists.php.net
Subject: Re: [PHP] pup

ramesh.marimu...@wipro.com wrote:
 
Hi,
 
I'm new to php.

Say I have a check box which is checked already. Now I need to uncheck



it and when I press the submit button, I should get the unchecked

value.

Can anyone help me on this.

One.php

if($qry[0]!=$login_type)
{
echo "style=background-color:#CC66CC>value=a".$count." checked DISABLED />".$slot_value.""; } 
else { echo "style=background-color:#00>value='--user ".$slot_value." --ne ".$nen." --timespec ".$slt."' 
checked

".$slot_value."";

}

One.php calls Two.php
Two.php

$enable_slot= $_POST['enable'];
$uncheck_slot= $_POST['uncheck'];

if ($enable_slot){
echo "$enable_slot";
foreach($enable_slot as &$a) {
echo "".$a." --unreserve";
}
}

I get only the results only if checked. I think I'm doing a mistake in



the code in red font.

regards,
-rummy

 


When you uncheck a checkbox in an HTML form, it will not be submitted.

http://www.w3.org/TR/html401/interact/forms.html#checkbox

The part on the above page talking about "only "on" checkbox controls
can become successful." is the key here.

The successful part links here:

http://www.w3.org/TR/html401/interact/forms.html#successful-controls

This explains that the definition of a successful checkbox submission is
one that is  "on".
To have a checkbox in the "on" state means that it has to be checked.

So, any checkbox that is /not/ checked is considered "off" or
"undefined" will not be submitted because it is not valid.

Or something like that... :)

Jim Lucas

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 


www.wipro.com



Maybe create a hidden input tag right next to it that references some default 
value.

Why are you wanting to get a value if it is not checked?

If this is what you are looking for are you sure that a checkbox is the right 
form input type to be using?

Jim Lucas

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



Re: [PHP] pup

2009-04-16 Thread Jim Lucas

ramesh.marimu...@wipro.com wrote:

I'm developing a slot reservation page. It shows checked boxes for the
currently logged user. If he likes to unreserve it, he should uncheck
it. For other users it is disabled. Also a currently logged user can
book another slot.

Also when I use hidden types, only if all the checked boxes are
unchecked, I could get the hidden values.

-rummy



You could use an array system in your checkbox form section.?

Basically, take your check boxes.  I am assuming that you have a defined list 
of what is expected?  Correct?

Have your elements setup like such:



 Room #1
 Room #2
 Room #3
 Room #4
 Room #5


Then on your processing page, you know that you have 5 rooms, 1 - 5.

With this information you can check to make sure that something exists



Something like that should do the trick.

Jim Lucas

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



RE: [PHP] pup

2009-04-16 Thread ramesh.marimuthu

Many Thanks Jim. Your idea worked.

-rummy

-Original Message-
From: Jim Lucas [mailto:li...@cmsws.com]
Sent: Friday, April 17, 2009 11:13 AM
To: Ramesh Marimuthu (WT01 - Telecom Equipment); PHP General List;
geek...@gmail.com
Subject: Re: [PHP] pup

ramesh.marimu...@wipro.com wrote:
> I'm developing a slot reservation page. It shows checked boxes for the

> currently logged user. If he likes to unreserve it, he should uncheck
> it. For other users it is disabled. Also a currently logged user can
> book another slot.
>
> Also when I use hidden types, only if all the checked boxes are
> unchecked, I could get the hidden values.
>
> -rummy
>

You could use an array system in your checkbox form section.?

Basically, take your check boxes.  I am assuming that you have a defined
list of what is expected?  Correct?

Have your elements setup like such:



 Room #1  Room #2  Room #3  Room #4  Room #5


Then on your processing page, you know that you have 5 rooms, 1 - 5.

With this information you can check to make sure that something exists



Something like that should do the trick.

Jim Lucas

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.

www.wipro.com

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