php-general Digest 26 Aug 2010 14:15:04 -0000 Issue 6911

2010-08-26 Thread php-general-digest-help

php-general Digest 26 Aug 2010 14:15:04 - Issue 6911

Topics (messages 307679 through 307700):

Re: Web application architecture (subdomain vs. sub directory)
307679 by: Per Jessen
307680 by: Per Jessen
307681 by: Peter Lind
307682 by: Per Jessen
307694 by: tedd
307695 by: tedd
307697 by: Bob McConnell

XML with PHP
307683 by: user.domain.invalid
307684 by: Michael Shadle
307685 by: Michael Shadle
307686 by: Sridhar Pandurangiah
307687 by: Sridhar Pandurangiah
307688 by: Sridhar Pandurangiah
307689 by: Sridhar Pandurangiah
307690 by: Sridhar Pandurangiah
307691 by: Sridhar Pandurangiah
307692 by: Sridhar Pandurangiah

Re: two questions on serverside validation
307693 by: tedd

Variable in variable.
307696 by: João Cândido de Souza Neto
307698 by: Robert Cummings
307699 by: João Cândido de Souza Neto

Does array_splice() fit for case ?
307700 by: Alfredo Palhares

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Tim Martens wrote:

 Thanks for all your answers. To clarify my question, I'm looking for
 advice regarding how best to set up users for a web app, e.g.,
 username.myapp.com vs myapp.com/username and the pros and cons of
each.

Using username.myapp.com means defining that name in your DNS and having
a separate virtual host definition in your apache config. 

Using myapp.com/username means having one virtual host, and no extra DNS
records. 

One is not necessarily better or worse than the other - to me it's
mostly about presentation and I would go for the myapp.com/username
option.  This (in my mind) puts username a level lower than myapp,
whereas username.myapp.com does the opposite. 


-- 
Per Jessen, Zürich (17.7°C)

---End Message---
---BeginMessage---
Shreyas Agasthya wrote:

 I am not sure who the end-users are for your website but if you are
 concerned about scalability, I would definitely go for a sub-domain
 approach. Assuming you approach a CDN like Akamai and you want to
 offload the traffic to come from the cloud, it's lot easier for you to
 integrate with them and to maintain.
 
 The subdirectory approach, whereas, is very cumbersome and  takes more
 work at your end to paraphrase the whole set-up should the needs
 change going forward.

The subdirectory approach is easily rewritten to an internal subdomain
structure. 



-- 
Per Jessen, Zürich (17.7°C)

---End Message---
---BeginMessage---
On 26 August 2010 08:08, Per Jessen p...@computer.org wrote:
 Tim Martens wrote:

 Thanks for all your answers. To clarify my question, I'm looking for
 advice regarding how best to set up users for a web app, e.g.,
 username.myapp.com vs myapp.com/username and the pros and cons of
 each.

 Using username.myapp.com means defining that name in your DNS and having
 a separate virtual host definition in your apache config.


While offtopic and nothing to do with PHP I think this should be
corrected: you can set a *.yourdomain rule which matches all
subdomains not explicitly set. So no, you do not need to define every
single name as a DNS record.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype
---End Message---
---BeginMessage---
Peter Lind wrote:

 On 26 August 2010 08:08, Per Jessen p...@computer.org wrote:
 Tim Martens wrote:

 Thanks for all your answers. To clarify my question, I'm looking for
 advice regarding how best to set up users for a web app, e.g.,
 username.myapp.com vs myapp.com/username and the pros and cons of
 each.

 Using username.myapp.com means defining that name in your DNS and
 having a separate virtual host definition in your apache config.

 
 While offtopic and nothing to do with PHP I think this should be
 corrected: you can set a *.yourdomain rule which matches all
 subdomains not explicitly set. So no, you do not need to define every
 single name as a DNS record.

Good point. Not sure I would personally want to use wildcards, but it's
perfectly valid. 



-- 
Per Jessen, Zürich (17.7°C)

---End Message---
---BeginMessage---

At 1:45 PM -0500 8/25/10, Tim Martens wrote:

Hi Everyone,

New to the list. Hello!

I'm in the customer discovery phase for a Health IT web application concept
I have. My programmer is new to web apps, but not to programming and is set
up with LAM(PHP). We're still debating weather to use a framework or to go
with Rasmus's no framework framework approach.

Language/Framework decisions aside... my main question is about subdomain (

Re: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread Per Jessen
Tim Martens wrote:

 Thanks for all your answers. To clarify my question, I'm looking for
 advice regarding how best to set up users for a web app, e.g.,
 username.myapp.com vs myapp.com/username and the pros and cons of
each.

Using username.myapp.com means defining that name in your DNS and having
a separate virtual host definition in your apache config. 

Using myapp.com/username means having one virtual host, and no extra DNS
records. 

One is not necessarily better or worse than the other - to me it's
mostly about presentation and I would go for the myapp.com/username
option.  This (in my mind) puts username a level lower than myapp,
whereas username.myapp.com does the opposite. 


-- 
Per Jessen, Zürich (17.7°C)


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



Re: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread Per Jessen
Shreyas Agasthya wrote:

 I am not sure who the end-users are for your website but if you are
 concerned about scalability, I would definitely go for a sub-domain
 approach. Assuming you approach a CDN like Akamai and you want to
 offload the traffic to come from the cloud, it's lot easier for you to
 integrate with them and to maintain.
 
 The subdirectory approach, whereas, is very cumbersome and  takes more
 work at your end to paraphrase the whole set-up should the needs
 change going forward.

The subdirectory approach is easily rewritten to an internal subdomain
structure. 



-- 
Per Jessen, Zürich (17.7°C)


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



Re: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread Peter Lind
On 26 August 2010 08:08, Per Jessen p...@computer.org wrote:
 Tim Martens wrote:

 Thanks for all your answers. To clarify my question, I'm looking for
 advice regarding how best to set up users for a web app, e.g.,
 username.myapp.com vs myapp.com/username and the pros and cons of
 each.

 Using username.myapp.com means defining that name in your DNS and having
 a separate virtual host definition in your apache config.


While offtopic and nothing to do with PHP I think this should be
corrected: you can set a *.yourdomain rule which matches all
subdomains not explicitly set. So no, you do not need to define every
single name as a DNS record.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread Per Jessen
Peter Lind wrote:

 On 26 August 2010 08:08, Per Jessen p...@computer.org wrote:
 Tim Martens wrote:

 Thanks for all your answers. To clarify my question, I'm looking for
 advice regarding how best to set up users for a web app, e.g.,
 username.myapp.com vs myapp.com/username and the pros and cons of
 each.

 Using username.myapp.com means defining that name in your DNS and
 having a separate virtual host definition in your apache config.

 
 While offtopic and nothing to do with PHP I think this should be
 corrected: you can set a *.yourdomain rule which matches all
 subdomains not explicitly set. So no, you do not need to define every
 single name as a DNS record.

Good point. Not sure I would personally want to use wildcards, but it's
perfectly valid. 



-- 
Per Jessen, Zürich (17.7°C)


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



[PHP] XML with PHP

2010-08-26 Thread user

Hi

I am trying to read XML files (invoices) from a directory and display 
them to the visitor. Each XML file contains several invoices. The 
visitor then clicks on the XML file (invoices). My PHP snippet should 
open the xml file and locate the appropriate invoice and display the 
content.


I have managed to list the directory contents using the following PHP 
snippet. The function call below DisplayBill($MemberId, $FileName, 
$StyleSheet) should take the memberid (login), the xml file name which 
has been clicked and the stylesheet to be used.


I now have the following doubts for which I need clarifications

Architecturally is it necessary the DisplayBill should be a seperate php 
file or can it exist as a function in the same file as the code below?


Should the Invoices be displayed as a web form for me to capture the 
user click to retrieve the appropriate file and invoice so that I can 
display it to the user.


I intend to parse the XML file using XPath (at this stage I am not sure 
if php supports Xpath and XQuery!)


Any help would be appreciated

Best regards

Sridhar

-

?php
$BillLocation = /home/cmi/Integration/xml_files;
$StyleSheet = Bill.xsl;
$DirHandle = opendir($BillLocation);
echo table border=\1\;
echo tr;
While (($FileName = readdir($DirHandle)) !== false)
{
if ($FileName != .  $FileName != ..)
{
if (strpos($FileName, xml) !== false)
{
$BillYear = substr($FileName, 0, 4);
$BillMonth = substr($FileName, 5, 2);
switch ($BillMonth)
{
case 01:
$BillMonth = January;
break;
case 02:
$BillMonth = February;
break;
case 03:
$BillMonth = March;
break;
case 04:
$BillMonth = April;
break;
case 05:
$BillMonth = May;
break;
case 06:
$BillMonth = June;
break;
case 07:
$BillMonth = July;
break;
case 08:
$BillMonth = August;
break;
case 09:
$BillMonth = September;
break;
case 10:
$BillMonth = October;
break;
case 11:
$BillMonth = November;
break;
case 12:
$BillMonth = December;
break;
}
			echo td . a href='$FileName'$BillMonth .   . 
$BillYear/a . /td . \n;

echo /tr;

}
}
}
echo /table;
closedir($DirHandle);

$result = DisplayBill($MemberId, $FileName, $StyleSheet);

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



Re: [PHP] XML with PHP

2010-08-26 Thread Michael Shadle
On Thu, Aug 26, 2010 at 2:54 AM,  u...@domain.invalid wrote:
 Hi

 I am trying to read XML files (invoices) from a directory and display them
 to the visitor. Each XML file contains several invoices. The visitor then
 clicks on the XML file (invoices). My PHP snippet should open the xml file
 and locate the appropriate invoice and display the content.

a) first, your email address isn't correct

b) second, it looks like you intend on applying a stylesheet to get
your results. if you don't require XSL, you could look at just using
PHP's simplexml and/or XML DOM functions. it looks like you might just
be using the XSL to transform the XML anwyay; so from what it looks
like you -do not- need XSL in the mix.

c) you can put the PHP in any file you want

d) i believe xpath should work without any problems.

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



Re: [PHP] XML with PHP

2010-08-26 Thread Michael Shadle
On Thu, Aug 26, 2010 at 3:10 AM, Sridhar Pandurangiah
sridharpa...@gmail.com wrote:
 Mike

 Thanks a ton for the quick response. I have updated the mail id on my email
 client (using Mozilla TB) and I did repost but your reply was quicker!

 Will try this out and post the results on this thread. Just waiting for
 someone to throw light on how to capture the filename that the user
 clicked. Should I display the directory listing as a form?

honestly, that's a little bit too i'm writing code and solving all
your problems for you for me... it's hard to concentrate, i have to
actually do the code, not read about it and try to figure it out from
a description :)

feel free to pastebin it, if i don't help you quick maybe someone else will.

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



[PHP] XML with PHP

2010-08-26 Thread Sridhar Pandurangiah

Hi

I am trying to read XML files (invoices) from a directory and display
them to the visitor. Each XML file contains several invoices. The
visitor then clicks on the XML file (invoices). My PHP snippet should
open the xml file and locate the appropriate invoice and display the
content.

I have managed to list the directory contents using the following PHP
snippet. The function call below DisplayBill($MemberId, $FileName,
$StyleSheet) should take the memberid (login), the xml file name which
has been clicked and the stylesheet to be used.

I now have the following doubts for which I need clarifications

Architecturally is it necessary the DisplayBill should be a seperate php
file or can it exist as a function in the same file as the code below?

Should the Invoices be displayed as a web form for me to capture the
user click to retrieve the appropriate file and invoice so that I can
display it to the user.

I intend to parse the XML file using XPath (at this stage I am not sure
if php supports Xpath and XQuery!)

Any help would be appreciated

Best regards

Sridhar

-

?php
$BillLocation = /home/cmi/Integration/xml_files;
$StyleSheet = Bill.xsl;
$DirHandle = opendir($BillLocation);
echo table border=\1\;
echo tr;
While (($FileName = readdir($DirHandle)) !== false)
{
if ($FileName != .  $FileName != ..)
{
if (strpos($FileName, xml) !== false)
{
$BillYear = substr($FileName, 0, 4);
$BillMonth = substr($FileName, 5, 2);
switch ($BillMonth)
{
case 01:
$BillMonth = January;
break;
case 02:
$BillMonth = February;
break;
case 03:
$BillMonth = March;
break;
case 04:
$BillMonth = April;
break;
case 05:
$BillMonth = May;
break;
case 06:
$BillMonth = June;
break;
case 07:
$BillMonth = July;
break;
case 08:
$BillMonth = August;
break;
case 09:
$BillMonth = September;
break;
case 10:
$BillMonth = October;
break;
case 11:
$BillMonth = November;
break;
case 12:
$BillMonth = December;
break;
}
echo td . a href='$FileName'$BillMonth .   .
$BillYear/a . /td . \n;
echo /tr;

}
}
}
echo /table;
closedir($DirHandle);

$result = DisplayBill($MemberId, $FileName, $StyleSheet);

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



Re: [PHP] XML with PHP

2010-08-26 Thread Sridhar Pandurangiah

Hi

I guess my post was misunderstood. I was just trying to figure out if 
there is a better way other than displaying a form. That's the reason I 
posted my php snippet in my first post.


Thanks for the help.

Best regards

Sridhar

 Original Message 
Subject: Re: [PHP] XML with PHP
From: mike...@gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:43:33 GMT+0530 (IST)

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



Re: [PHP] XML with PHP

2010-08-26 Thread Sridhar Pandurangiah

Mike

Thanks a ton for the quick response. I have updated the mail id on my 
email client (using Mozilla TB) and I did repost but your reply was quicker!


Will try this out and post the results on this thread. Just waiting for 
someone to throw light on how to capture the filename that the user 
clicked. Should I display the directory listing as a form?


Best regards

Sridhar

 Original Message 
Subject: Re: [PHP] XML with PHP
From: mike...@gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:32:13 GMT+0530 (IST)


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



Re: [PHP] two questions on serverside validation

2010-08-26 Thread tedd

At 3:59 PM +0100 8/25/10, Ashley Sheridan wrote:


2.4 seconds doesn't seem so bad on 10 million iterations, but yes, it
does show that you should avoid it if it's really not necessary. Most
often I'll use that sort of syntax if I do something like this:

$greeting = Hello $name, not seen you since $date;

which might be slower than:

$greeting = 'Hello ' . $name . ', not seen you since ' . $date;

but it is a whole lot neater and still gets syntax highlighting applied
in a decent IDE or editor.

Thanks,
Ash



Agreed.

Making things easy for both you and the programmer who follows is 
more important than cutting a few nanoseconds off compute time. After 
all, just displaying that information (i.e., echo) will take far more 
time and even vary more than that between monitors.


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread tedd

At 1:45 PM -0500 8/25/10, Tim Martens wrote:

Hi Everyone,

New to the list. Hello!

I'm in the customer discovery phase for a Health IT web application concept
I have. My programmer is new to web apps, but not to programming and is set
up with LAM(PHP). We're still debating weather to use a framework or to go
with Rasmus's no framework framework approach.

Language/Framework decisions aside... my main question is about subdomain (
customerx.appname.com vs subdirectory (appname.com/customerx/) models for
instances of individual customers' accounts.

It seems most people are opting for the former -- is this but a trebd? --
but I see flickr use the latter. The guys at Particletree (i.e., Wufoo)
wrote a blog post about it (
http://particletree.com/notebook/subdomains-development-sucks/) years ago to
which they still attest.

They say the subdirectory model is much easier and faster to develop and
deploy. We are developing locally on our macs and will be using
Mecurial/Bitbucket for CVS.

I'm really lost on this issue as all my searches turn up stuff on SEO/SEM.
Is one approach easier that the other? What about security and scalability
considerations? I would very much appreciate your opinions as to the pros
and cons of each approach.

As an aside, does anyone have some advice about rapid PHP deployment, i.e.,
pushing new features to production daily in micro iterations vs the typical
milestone approach? Are there any good tools for this? What about hosts?

Thanks all,

Tim


Tim:

My recommendations:

1. No framework. Learn one thing, namely what you want to do and not 
two (i.e., what you want to do and a framework). I did not know 
that Rasmus said that, but I listen to what he says.


2. Use directories. They are much simpler to use and easy to 
create/change/delete/scale/make-secure. -- SEO stuff does not apply 
here.


3. Investigate Agile development.

4. Host? Roll the dice like the rest of us.

Cheers,

tedd
--
---
http://sperling.com/

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



Re: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread tedd

At 4:45 PM -0500 8/25/10, Tim Martens wrote:

Thanks for all your answers. To clarify my question, I'm looking for advice
regarding how best to set up users for a web app, e.g., username.myapp.comvs
myapp.com/username and the pros and cons of each. All users will be using
essentially the same app that will have their data in their account. I can
see the logic of setting up subdomain for things like a universal login and,
say, metrics for example.

Is javascripting more difficult across subdomains? Is one approach beter in
terms of security? Essentially the entire app will be running on https.

Thanks again!

Tim



Tim:

That's a different question -- you should post another question 
rather than continue the old thread regarding something else.


Cheers,

tedd
--
---
http://sperling.com/

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



RE: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread Bob McConnell
From: tedd

 At 1:45 PM -0500 8/25/10, Tim Martens wrote:
Hi Everyone,

New to the list. Hello!

I'm in the customer discovery phase for a Health IT web application
concept
I have. My programmer is new to web apps, but not to programming and
is set
up with LAM(PHP). We're still debating weather to use a framework or
to go
with Rasmus's no framework framework approach.

Language/Framework decisions aside... my main question is about
subdomain (
customerx.appname.com vs subdirectory (appname.com/customerx/) models
for
instances of individual customers' accounts.

It seems most people are opting for the former -- is this but a trebd?
--
but I see flickr use the latter. The guys at Particletree (i.e.,
Wufoo)
wrote a blog post about it (
http://particletree.com/notebook/subdomains-development-sucks/) years
ago to
which they still attest.

They say the subdirectory model is much easier and faster to develop
and
deploy. We are developing locally on our macs and will be using
Mecurial/Bitbucket for CVS.

I'm really lost on this issue as all my searches turn up stuff on
SEO/SEM.
Is one approach easier that the other? What about security and
scalability
considerations? I would very much appreciate your opinions as to the
pros
and cons of each approach.

As an aside, does anyone have some advice about rapid PHP deployment,
i.e.,
pushing new features to production daily in micro iterations vs the
typical
milestone approach? Are there any good tools for this? What about
hosts?

Thanks all,

Tim

 Tim:
 
 My recommendations:
 
 1. No framework. Learn one thing, namely what you want to do and not 
 two (i.e., what you want to do and a framework). I did not know 
 that Rasmus said that, but I listen to what he says.
 
 2. Use directories. They are much simpler to use and easy to 
 create/change/delete/scale/make-secure. -- SEO stuff does not apply 
 here.
 
 3. Investigate Agile development.
 
 4. Host? Roll the dice like the rest of us.

Before you can select a hosting provider, define what you want. Are you
looking for a cage with power and network connections, a VM that you can
load up and manage, or a fully managed server environment? UPS or
generator? What about backup and failover? Do you need redundant network
connections? There is a wide range of options here that are not easy to
evaluate. We have used a variety of different hosts through the years as
our needs and requirements changed. Our current one is fully managed,
guarantees PCI compliance and is very expensive. But it is still less
than the FTE we would have to hire to do it all ourselves. We have more
than 100 client sites on that cluster of servers.

Depending on your size, it may be worth considering hiring a consultant
to walk you through this process the first time. It could save you a lot
of mistakes, time and money.

Bob McConnell

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



Re: [PHP] Variable in variable.

2010-08-26 Thread Robert Cummings

On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote:

I know that in PHP I can use this:

$var1 = text;
$var2 = '$var1';
4cho $$var2;

So it gives me text.


It would if you didn't have typos and the wrong quotes in the above :)


My question is, is there a way of doing it with constant like this?

define(CONST, text);
$test = CONST;
echo $$test;

So it gives me text.


http://ca3.php.net/manual/en/function.constant.php

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Variable in variable.

2010-08-26 Thread Jo�o C�ndido de Souza Neto
Really cool...

Thanks and fogive me by my mistake. hehe

-- 
João Cândido de Souza Neto

Robert Cummings rob...@interjinn.com escreveu na mensagem 
news:4c76743a.2060...@interjinn.com...
 On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote:
 I know that in PHP I can use this:

 $var1 = text;
 $var2 = '$var1';
 4cho $$var2;

 So it gives me text.

 It would if you didn't have typos and the wrong quotes in the above :)

 My question is, is there a way of doing it with constant like this?

 define(CONST, text);
 $test = CONST;
 echo $$test;

 So it gives me text.

 http://ca3.php.net/manual/en/function.constant.php

 Cheers,
 Rob.
 -- 
 E-Mail Disclaimer: Information contained in this message and any
 attached documents is considered confidential and legally protected.
 This message is intended solely for the addressee(s). Disclosure,
 copying, and distribution are prohibited unless authorized. 



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



[PHP] Does array_splice() fit for case ?

2010-08-26 Thread Alfredo Palhares
Hello,

This is kinda a noob question, but that's what i am :)

I have a 2 dimensions array (the first dimension are normal keys ) and in
the second dimension haves custom arrays but they all have a comon key that
is *id.
*The array comes ascending ordered by the numbers of *id* .

When i receive this array i need to look for and array that haves the
*id*== 0, so i do a for  loop looking for it  and i unset this values
after
that.
But need i need that the unset array looks like this sub-array never existed
( eg. if the key that with id = 0  was 5, the 5 will the number 6 and
6 the 7 and so on).
Here is the code:

?php

// $data the name of the array

//Look for the main email
for ($i = 0; $i  count($data); $i++) {
 if ($data[$i]['id'] === 0) {
 // It can't be empty
 if (!empty($data[$i])) {
 $this-email = $data[$i]['contact'];
 $main_email_found = true;
 }
 unset($data[$i]);
 }
}
?

I have tree ways of doing this:

- Use a method that i that looks from duplicate entru based on the *id *key
as index and after and return the array ordered by this index.
- Adding a new entry to another array in this loop that not haves the
*id*== 0. and after that reverse the order
- Use the array_splice native function.

What do you recommend me ?
Sorry by the bad English.


-- 
Regards,
Alfredo Palhares


RE: [PHP] Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread tedd

At 9:58 AM -0400 8/26/10, Bob McConnell wrote:

From: tedd

 

 4. Host? Roll the dice like the rest of us.


Before you can select a hosting provider, define what you want. Are you
looking for a cage with power and network connections, a VM that you can
load up and manage, or a fully managed server environment? UPS or
generator? What about backup and failover? Do you need redundant network
connections? There is a wide range of options here that are not easy to
evaluate. We have used a variety of different hosts through the years as
our needs and requirements changed. Our current one is fully managed,
guarantees PCI compliance and is very expensive. But it is still less
than the FTE we would have to hire to do it all ourselves. We have more
than 100 client sites on that cluster of servers.

Depending on your size, it may be worth considering hiring a consultant
to walk you through this process the first time. It could save you a lot
of mistakes, time and money.

Bob McConnell



Which I am sure is good advice.

Cheers,

tedd

--
---
http://sperling.com/

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



[PHP] Upload using FTP commands

2010-08-26 Thread Matthew Croud


Hi,

I want to give my client the ability to upload large files ( around  
20MB ) to a webspace.
I reckon that using the FTP commands of PHP would be the best bet, but  
is it possible to allow them to do this through an online form.


This is my vision: the client logs in to a form that has an upload  
button, and the upload button uses the FTP commands to upload the file.


Is that do-able in PHP ?

Cheers!







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



[PHP] pecl/oauth - possible to send HTTP request myself?

2010-08-26 Thread Marc Abramowitz
The typical way to use pecl/oauth seems to use OAuth::fetch which does 
everything including sending the HTTP request using curl or php streams.

I'd like to be able to use pecl/oauth to do everything up to and including 
calculating the signature but then send the request using different code. The 
reason for this is that I am using a web framework (internal) that can 
aggregate requests using curl_multi and do them asynchronously (Rasmus surely 
knows what I'm referring to :-)). I imagine this could be useful also for 
others who need to make their requests go through proxies.

I know that I can call oauth_get_sbs to get the sbs which is probably the most 
error-prone part of doing OAuth so that's good. But is it possible to take it a 
step further and get pecl/oauth to return the curl handle it would've used 
(with OAuth stuff already stuffed in the url or request headers) without 
executing it?

Basically I want to decouple OAuth signature calculation from network 
communication. Possible?

-Marc
http://marc-abramowitz.com
Sent from my iPhone 3G




Re: [PHP] Upload using FTP commands

2010-08-26 Thread Dan McCullough
Take a look here:
http://us.php.net/manual/en/ref.ftp.php

You might have some issues with the memory limit in PHP so that might have
to be boosted for 20MB files.

On Thu, Aug 26, 2010 at 12:24 PM, Matthew Croud m...@obviousdigital.comwrote:


 Hi,

 I want to give my client the ability to upload large files ( around 20MB )
 to a webspace.
 I reckon that using the FTP commands of PHP would be the best bet, but is
 it possible to allow them to do this through an online form.

 This is my vision: the client logs in to a form that has an upload button,
 and the upload button uses the FTP commands to upload the file.

 Is that do-able in PHP ?

 Cheers!







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




[PHP] Re: Upload using FTP commands

2010-08-26 Thread Jo�o C�ndido de Souza Neto
A form sendind a file has nothing to do with FTP functions of PHP.

You´ll still need to change de upload_max_filesize and so on in order to 
send such files to the server.

-- 
João Cândido de Souza Neto

Matthew Croud m...@obviousdigital.com escreveu na mensagem 
news:02f75bf6-9ec5-4456-9150-07042aeba...@obviousdigital.com...

 Hi,

 I want to give my client the ability to upload large files ( around 
  20MB ) to a webspace.
 I reckon that using the FTP commands of PHP would be the best bet, but  is 
 it possible to allow them to do this through an online form.

 This is my vision: the client logs in to a form that has an upload 
 button, and the upload button uses the FTP commands to upload the file.

 Is that do-able in PHP ?

 Cheers!





 



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



Re: [PHP] Upload using FTP commands

2010-08-26 Thread Ashley Sheridan
On Thu, 2010-08-26 at 17:24 +0100, Matthew Croud wrote:

 Hi,
 
 I want to give my client the ability to upload large files ( around  
 20MB ) to a webspace.
 I reckon that using the FTP commands of PHP would be the best bet, but  
 is it possible to allow them to do this through an online form.
 
 This is my vision: the client logs in to a form that has an upload  
 button, and the upload button uses the FTP commands to upload the file.
 
 Is that do-able in PHP ?
 
 Cheers!
 
 
 
 
 
 
 

What would be the point?

You would have to set up your server to allow large files to be uploaded
in order for them to be used by PHP, and by that time, unless you're
putting them onto a remote server, there's no point in using the FTP
functions of PHP. What I've found quite reliable is to use PHP to create
FTP user accounts, which they can then log in to and upload files as
they need.

HTTP was not really intended for uploading large files, but FTP is, and
every OS has some form of FTP software built in that can be used very
easily.

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




Re: [PHP] tutorial failure

2010-08-26 Thread e-letter
On 20/08/2010, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 You don't have to reinstall the entire OS, that's a very Windows
 approach to the problem. I played around a bit last night with urpmi and
 you should be able to just list the packages you need with urpmq --fuzzy
 package_name, and then install the ones listed you think you need. I did
 notice that urpmi doesn't install the DB when you install the Apache mod
 for that DB, so you might need to install that separately, but other
 than that, you should be good to go if you install the Apache php mod.


True with respect to the windoze mentality but I had other reasons to
reformat the pc so this was a good opportunity.

The resultant web page is:

Hi, I am a PHP script

this is a test

However, the manual page implies to me that the web page should have
shown the html code, i.e.

html
 head
 titlephp test
 /title
 /head
 body
 pHi, I am a PHP script/p
 pthis is a test/p
 /body
/html

The source code of the web page:

html
 head
 titlephp test
 /title
 /head
 body
 pHi, I am a PHP script/pp
 this is a test
 /p
 /body
/html

Is this an error with the explanation of the manual or is the
apache-php configuration still at fault?

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



Re: [PHP] tutorial failure

2010-08-26 Thread Ashley Sheridan
On Thu, 2010-08-26 at 17:45 +0100, e-letter wrote:

 On 20/08/2010, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
  You don't have to reinstall the entire OS, that's a very Windows
  approach to the problem. I played around a bit last night with urpmi and
  you should be able to just list the packages you need with urpmq --fuzzy
  package_name, and then install the ones listed you think you need. I did
  notice that urpmi doesn't install the DB when you install the Apache mod
  for that DB, so you might need to install that separately, but other
  than that, you should be good to go if you install the Apache php mod.
 
 
 True with respect to the windoze mentality but I had other reasons to
 reformat the pc so this was a good opportunity.
 
 The resultant web page is:
 
 Hi, I am a PHP script
 
 this is a test
 
 However, the manual page implies to me that the web page should have
 shown the html code, i.e.
 
 html
  head
  titlephp test
  /title
  /head
  body
  pHi, I am a PHP script/p
  pthis is a test/p
  /body
 /html
 
 The source code of the web page:
 
 html
  head
  titlephp test
  /title
  /head
  body
  pHi, I am a PHP script/pp
  this is a test
  /p
  /body
 /html
 
 Is this an error with the explanation of the manual or is the
 apache-php configuration still at fault?
 


The manual page says that the output is the HTML code, which is exactly
what you're getting. Your browser is responsible for interpreting those
tags, based on the mime header that it receives from PHP (which is
text/html by default) You should only ever need to change this header
when you are outputting some other type of content, like XML, an image,
etc.

If you change your PHP script and add this line before you output any
content you will see the tags as your browser will interpret them as
plain text (Internet Explorer may screw this up, as it tends to ignore
header mime types more often than not):

header(Content-type: text/plain);

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




[PHP] Re: Web application architecture (subdomain vs. sub directory)

2010-08-26 Thread Tim Martens
Thank you everyone for your generous feedback. It's given me a lot to think
about. I now realize that my question has as much to do with DNS and Apache
as with PHP. As we clarify the functionality and essence of the app, I'll
post again with more focussed questions.

Based on advice here and elsewhere, I think we're tending toward a an no
framework MVC approach and sub-directory model to get started. As Per so
elegantly stated The subdirectory approach is easily rewritten to an
internal subdomain
structure. So if we need to pivot to a subdomain model we can do so.

Tim


Re: [PHP] Upload using FTP commands

2010-08-26 Thread Adam Richardson
On Thu, Aug 26, 2010 at 12:37 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Thu, 2010-08-26 at 17:24 +0100, Matthew Croud wrote:

  Hi,
 
  I want to give my client the ability to upload large files ( around
  20MB ) to a webspace.
  I reckon that using the FTP commands of PHP would be the best bet, but
  is it possible to allow them to do this through an online form.
 
  This is my vision: the client logs in to a form that has an upload
  button, and the upload button uses the FTP commands to upload the file.
 
  Is that do-able in PHP ?
 
  Cheers!
 
 
 
 
 
 
 

 What would be the point?

 You would have to set up your server to allow large files to be uploaded
 in order for them to be used by PHP, and by that time, unless you're
 putting them onto a remote server, there's no point in using the FTP
 functions of PHP.


Ashley makes a nice point.  When I have control over the server, I don't use
PHP's FTP capabilities at all.  However, on some shared severs you're only
HTTP upload options are to set a directory to 777 (Yikes!), or do some work
with PHP's FTP functions.

What I've done in the past on shared hosts is setup an upload FTP account
that has access to one directory.  Then, I develop a form to upload the
file.  Once a file is uploaded, I use PHP's FTP functions to place the file
in the directory.  This way I avoid the security issues of 777, maintain an
easy-to-use interface (some clients don't want to use FTP), and continue to
use the hosting the client prefers.  There is a cost to this method, but
sometimes it's worth the cost.

Just another way of doing things.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


[PHP] Making multiple RSS feeds for the blog website

2010-08-26 Thread Andre Polykanine
Hi everyone,
We are developing a blog service website.
What we need now is the ability to make multiple RSS feeds from
several pages (an RSS of each user's blog, a feed from each timeline -
timelines are our representation of users' favorites; a feed filled
with comments to a separate entry, etc.). What would be great is the
following: a user enters, say, in my blog and sees the mark that there
are RSS feeds. Then he/she clicks the mark or presses a keystroke
(Alt+J in IE8, for instance), finds the feed and double-clicks on it.
Then he/she can either read the feed or subscribe to it. The feeds
have usually file extensions of .rss or .xml.
Question: how do we do that with PHP?
Thanks!



-- 
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion


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



[PHP] Re: Making multiple RSS feeds for the blog website

2010-08-26 Thread Michelle Konzack
Hello Andre Polykanine,

Am 2010-08-27 02:52:48, hacktest Du folgendes herunter:
 Hi everyone,
 We are developing a blog service website.

Very interesting  ;-)

 Question: how do we do that with PHP?

By reading the Documentation...  :-D

html
head
titleBlubber Blog/title
  link rel=alternate type=application/rss+xml title=RSS href=index.rss 
/
  link rel=alternate type=application/rss+xml title=Foo href=foo.rss /
  link rel=alternate type=application/rss+xml title=Bar href=bar.rss /
/head
body


Thanks, Greetings and nice Day/Evening
Michelle Konzack

-- 
# Debian GNU/Linux Consultant ##
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsyst...@tdnet France EURL   itsyst...@tdnet UG (limited liability)
Owner Michelle KonzackOwner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France   77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

http://www.itsystems.tamay-dogan.net/  http://www.flexray4linux.org/
http://www.debian.tamay-dogan.net/ http://www.can4linux.org/

Jabber linux4miche...@jabber.ccc.de
ICQ#328449886

Linux-User #280138 with the Linux Counter, http://counter.li.org/


signature.pgp
Description: Digital signature


RE: [PHP] Making multiple RSS feeds for the blog website

2010-08-26 Thread Daevid Vincent
 

 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org] 
 Sent: Thursday, August 26, 2010 4:53 PM
 To: php-general
 Subject: [PHP] Making multiple RSS feeds for the blog website
 
 Hi everyone,
 We are developing a blog service website.
 What we need now is the ability to make multiple RSS feeds from
 several pages (an RSS of each user's blog, a feed from each timeline -
 timelines are our representation of users' favorites; a feed filled
 with comments to a separate entry, etc.). What would be great is the
 following: a user enters, say, in my blog and sees the mark that there
 are RSS feeds. Then he/she clicks the mark or presses a keystroke
 (Alt+J in IE8, for instance), finds the feed and double-clicks on it.
 Then he/she can either read the feed or subscribe to it. The feeds
 have usually file extensions of .rss or .xml.
 Question: how do we do that with PHP?
 Thanks!
 
 
 
 -- 
 With best regards from Ukraine,
 Andre
 Skype: Francophile
 Twitter: http://twitter.com/m_elensule
 Facebook: http://facebook.com/menelion

In otherwords, to paraphrase:

DBAG_MODE
We have this super cool new idea that's going to revolutionize the web and
blogs and cloud computing and we might even create our own new buzzword. We
heard you can do this with PHP. We just don't have any code written, so
could you guys write it for us. That'd be swell. kthxbye.

;-)

Dude. Andre. Let me break it down like a fraction, as to how this list
works.

YOU post some code that you are struggling with, or you post some SPECIFIC
question, and the generous subscribers to this list decide if your question
is worthy of their time to reply.

Your question (for lack of a better term) was devoid of either of those
things.

Now, had you said, How can I formulate an RSS feed?, I might point you to
this:
http://www.phpclasses.org/package/560-PHP-XML-RSS-feed-generator-for-conten
t-syndication-.html

Or if you had said, How does one double click? (since that is NOT a
web-friendly navigation method by default), I might point you in this
direction:

script
   onload = function () {
  document.getElementById(textarea).ondblclick = function () {
alert('Double Clicked!') }
   }
/script
then this in the body
textarea id=textarea/textarea 

Or even if you said, How do I steal, er um, read an XML file from another
site? Then someone might show you these functions (since you clearly
missed them when you RTFPM)
http://us2.php.net/manual/en/function.file-get-contents.php
http://us2.php.net/manual/en/ref.simplexml.php
http://us2.php.net/manual/en/book.dom.php

But again, your question was so vague that I (and everyone else) probably
has nowhere to begin to help you and therefore most likely won't. Given the
above advice, you might consider breaking your questions down into PHP
related specific examples.

/DBAG_MODE


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



Re: [PHP] Does array_splice() fit for case ?

2010-08-26 Thread viraj
hi alfredo.. i really love to help.. but could you please explain a
bit clear. may be with sample input arrays and the expected out put
array.

~viraj

On Thu, Aug 26, 2010 at 7:45 PM, Alfredo Palhares masterk...@gmail.com wrote:
 Hello,

 This is kinda a noob question, but that's what i am :)

 I have a 2 dimensions array (the first dimension are normal keys ) and in
 the second dimension haves custom arrays but they all have a comon key that
 is *id.
 *The array comes ascending ordered by the numbers of *id* .

 When i receive this array i need to look for and array that haves the
 *id*== 0, so i do a for  loop looking for it  and i unset this values
 after
 that.
 But need i need that the unset array looks like this sub-array never existed
 ( eg. if the key that with id = 0  was 5, the 5 will the number 6 and
 6 the 7 and so on).
 Here is the code:

 ?php

 // $data the name of the array

        //Look for the main email
        for ($i = 0; $i  count($data); $i++) {
             if ($data[$i]['id'] === 0) {
                 // It can't be empty
                 if (!empty($data[$i])) {
                     $this-email = $data[$i]['contact'];
                     $main_email_found = true;
                 }
                 unset($data[$i]);
             }
        }
 ?

 I have tree ways of doing this:

 - Use a method that i that looks from duplicate entru based on the *id *key
 as index and after and return the array ordered by this index.
 - Adding a new entry to another array in this loop that not haves the
 *id*== 0. and after that reverse the order
 - Use the array_splice native function.

 What do you recommend me ?
 Sorry by the bad English.


 --
 Regards,
 Alfredo Palhares


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