php-general Digest 16 Jun 2006 07:47:05 -0000 Issue 4188

Topics (messages 238113 through 238136):

Re: Simple blog software... Simple but clean code... suggestions?
        238113 by: Micky Hulse
        238114 by: Micky Hulse
        238117 by: Anthony Ettinger
        238122 by: Richard Lynch

Re: paging results in large resultsets: mysql vs postgresql?
        238115 by: Richard Lynch
        238125 by: D. Dante Lorenso
        238130 by: Richard Lynch

Re: How to run one php app from another?
        238116 by: Richard Lynch

Re: basic php problem
        238118 by: Richard Lynch

Re: Using PHP/HTML effectivly
        238119 by: Jochem Maas

Re: generating/transforming HTML so that it 'works' in a        flash file
        238120 by: Jochem Maas

Re: A tricky little problem
        238121 by: Richard Lynch

Re: serving video files with php
        238123 by: Richard Lynch

Re: progress monitor in php
        238124 by: Richard Lynch
        238133 by: weetat
        238134 by: Ruben Rubio Rey

Re: Replacing text with criteria
        238126 by: Rafael

Re: File Download Headers
        238127 by: Richard Lynch
        238128 by: Richard Lynch
        238129 by: Richard Lynch
        238132 by: Chris Shiflett

Re: Accepting File Uploads from CURL
        238131 by: Manuel Lemos

file_exists()  behind firewall
        238135 by: George Pitcher

<SELECT> tag and PHP
        238136 by: weetat

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Barry wrote:
Well if you have that often this case, i would prefer you code one for yourself.

Oh, for sure. I completely agree... For the longest time (i.e. the college years) I was against using other peoples blog software or scripts... I would have never learned anything about PHP if it was not for my choice to take the long route(s) and program what I could myself. Hehe, does that make sense? Lol.

Now-a-days (i.e. the starving freelance multimedia designer years), when I am pressed for time, I have no other choice than to bite the bullet and install something like (for example) Expression Engine.

Not sure where I am going with this. Lol, thanks for the response though, I really appreciate the motivation.

Cheers,
Micky

--- End Message ---
--- Begin Message ---
Dave Goodchild wrote:
www.abuddhistpodcast.com <http://www.abuddhistpodcast.com> and www.mediamasters.co.uk/dg/insp <http://www.mediamasters.co.uk/dg/insp>

Cool sites btw! Good work.  :)

Cheers,
M

--- End Message ---
--- Begin Message ---
echo $_GET['comment'] >> htdocs/comments.html


:)



On 6/15/06, Micky Hulse <[EMAIL PROTECTED]> wrote:
Dave Goodchild wrote:
> www.abuddhistpodcast.com <http://www.abuddhistpodcast.com> and
> www.mediamasters.co.uk/dg/insp <http://www.mediamasters.co.uk/dg/insp>

Cool sites btw! Good work.  :)

Cheers,
M

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




--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 2:17 pm, Micky Hulse wrote:
> Barry wrote:
>> Well if you have that often this case, i would prefer you code one
>> for
>> yourself.
>
> Oh, for sure. I completely agree... For the longest time (i.e. the
> college years) I was against using other peoples blog software or
> scripts... I would have never learned anything about PHP if it was not
> for my choice to take the long route(s) and program what I could
> myself.
> Hehe, does that make sense? Lol.
>
> Now-a-days (i.e. the starving freelance multimedia designer years),
> when
> I am pressed for time, I have no other choice than to bite the bullet
> and install something like (for example) Expression Engine.
>
> Not sure where I am going with this. Lol, thanks for the response
> though, I really appreciate the motivation.

Anybody who writes a decent blog system that everybody can use is then
flooded with a zillion "Feature Requests" and, ultimately, you end up
with Bloated Blog.

I do not forsee this problem going away.

Ditto for forums and shopping carts.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 11:11 am, D. Dante Lorenso wrote:
> I just discovered this neat little gem in MySQL which makes it easy to
> page large result sets:
>
>     * SELECT SQL_CALC_FOUND_ROWS *
>
>     * SELECT FOUND_ROWS()
>

> I can't seem to find the equivalent of it in PostgreSQL!  The only
> options I see are:
>
>    2.
>
>       Using PHP row seek and only selecting the number of rows I need.

    3. use the built-in "cursor" of PostgreSQL which pre-dates MySQL
LIMIT and OFFSET clauses, which are non-standard hacks Rasmus
introduced back in the day.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
3. use the built-in "cursor" of PostgreSQL which pre-dates MySQL
LIMIT and OFFSET clauses, which are non-standard hacks Rasmus
introduced back in the day.

Care to elaborate?  Cast into context of PDO if you can...?

Dante

--- End Message ---
--- Begin Message ---



On Thu, June 15, 2006 7:15 pm, D. Dante Lorenso wrote:
> Richard Lynch wrote:
>> 3. use the built-in "cursor" of PostgreSQL which pre-dates MySQL
>> LIMIT and OFFSET clauses, which are non-standard hacks Rasmus
>> introduced back in the day.
>
> Care to elaborate?  Cast into context of PDO if you can...?

I've forgotten the exact cursor syntax, but it's like:

$query = "declare cursor foo as select complicated query here";
$foo = pg_exec($connection, $query);
$query = "select 10 from foo";
$ten_rows = pg_exec($connection, $query);

I have completely forgotten the cursor query to get the number of
rows, but it's in the docs.

You are so totally on your own with that bleeding-edge PDO [bleep]. 
Sorry.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---

Just include 'a.php'; and it will get done.

On Thu, June 15, 2006 11:11 am, tedd wrote:
> Hi gang:
>
> This seems like so obvious a question, I am reluctant to ask.
>
> In any event, I simply want my php application to run another, like
> so:
>
> switch (option)
>    {
>    case a:
>    run a.php;
>    exit;
>    break;
>
>    case b:
>    run b.php;
>    exit;
>    break;
>
>    case c:
>    run c.php;
>    exit;
>    break;
>   }
>
> I know that from within an application I can run another php
> application via a user click (.e., button), or from javascript event
> (onclick), or even from cron. But, what if you want to run another
> application from the results of a calculation inside your main
> application without a "user trigger". How do you do that?
>
> I have tried header("Location: http://www.example.com/";); ob_start(),
> ob_flush() and such, but I can't get anything to work.
>
> Is there a way?
>
> Thanks.
>
> tedd
> --
> ------------------------------------------------------------------------------------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 8:11 am, Ross wrote:

> I want to set a page number of a page
>
> if(!isset($_REQUEST['page'])) {
> $page =$_REQUEST['page'] + 1;

These two together make no sense at all...

If the $_REQUEST['page'] is NOT set, then why use it?  It's NOT THERE.

> echo "page is ".$page; // this echos out page is 1
> }

Here is a more sensible approach:

//use page requested, or default to page 1:
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;

You can write that as a 6-line if statement if you like:

if (isset($_REQUEST['page']){
  $page = $_REQUEST['page'];
}
else{
  $page = 1;
}

> The problem is when I try and use $page further down in the body $page
> is 0

In that case, you are on ?page=2 in your script, and you didn't do
ANYTHING about $page in the original version.

> Question <?=$page; ?> <BR />
> <? echo "page is".$page; ?>
> <?=$question[($page-1)]; ?>
>
>
> I also get an undefined index notice
>
> Notice: Undefined index: page in
> c:\Inetpub\wwwroot\lss\module_one\evaluation.php on line 8
> page is 1
>
> but I though if I do a if(!isset($_REQUEST['page'])) this is the way
> to set
> a previously undefined index?

No.

isset() CHECKS if a variable/index is set.  It does not alter anything
at all.  It just tests.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
> On Thu, 2006-06-15 at 03:16, Larry Garfield wrote:
>> Another recommendation: Do not, under any circumstances, try to write your 
>> own 
>> template engine.  All you'll be doing is writing a syntax parser in PHP for 
>> another syntax that will give you fewer options, less flexibility, and worse 
>> performance than well-used native PHP.
>>
>> There ARE good PHP based template engines out there (Smarty, Flexy, PHPTal, 
>> etc.), written by people much smarter than you or I and field tested by 
>> thousands of people on more sites than you've ever used.  If you want to use 
>> a non-PHP-syntax for your template files, find one.  Don't write it.  You 
>> will thank yourself later.
> 
> While I understand where you're coming from with this, I think it
> depends on your goals. The "smart" or as I prefer "experienced" people
> out there that have written complex systems have done so by getting
> their feet wet and trying. If you have an idea, the inclination, and the
> time then I think it's a great idea to rebuild the wheel. How else would
> better wheels come about? :)

good question - my wheels always turn out lumpy ;-)

> 
> Cheers,
> Rob.

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
> 
> I suspect the first question would be if Flash people have bothered to
> document what HTML subset they support.

they do, to a point (although trying to figure out what is supported across
all version is painful) and reading what they do apparently support made me
cry.

> 
> And second is, wouldn't you have a lot more luck in a Flash forum?...

probably, I was kind of hoping that someone had made written something in php
already - figured I possibly wasn't the first to swim these waters.

that said the 'solution' I'm toying with currently is a slightly extended 
version
of the following :-) ...

$flashHTML = strip_tags($myHTML);

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 4:30 am, Ross wrote:
> I have a multiple choice quiz where the questions & answers are
> extracted
> from an external file
>
> $q1 = "what is the capital of Scotland "; $a1 = "Edinburgh"; $b1
> ="Glasgow";
> $c1 ="dundee"; $d1 ="Stirling"; $q1_answer = $a1;
> $q2 = "what is the capital of France"; $a2 = "Lyon"; $b2 ="Paris"; $c2
> ="Carcassonne"; $d2 ="Madrid"; $q2_answer = $b1;
>
> ?>
>
> These are fed into a page which displays the questions and displays a
> radio
> button to select the answer, the page is incremnted when a correct
> answer is
> given
>
> if  ($_POST['x']== $q1_answer) {
> $incrementedPage = $page + 1;
> header("Location: evaluation.php?page=$incrementedPage");
> }
>
> but how can I insert and compare the next question?

$q = ${'q'.$_GET['page']};
echo $q;

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 3:04 am, Andras Kende wrote:
> Is there any drawback servings video files through php downloader
> script on
> high load site?
>
> Or just straight link to the videos are more efficient?

TAANSTAAFL

There certainly IS some overhead using PHP downloader script, and a
straight link IS definitely more efficient.

The correct question is "HOW MUCH more efficient"

The correct answer is "You'll only know after you test on YOUR machine"

Note that the bandwidth is probably gonna kill you long before PHP
does, if you write a lean mean PHP application...

If your PHP download script has to include 4,000 class files before it
can do anything useful, well, no, it won't be fast.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 4:48 am, weetat wrote:
>    I was using PEAR:HTTP_Upload to upload file in php 4.3.2.
>    Is ok , however i need to display some sort of progress monitor to
> the user because some file is very large and took some times to
> upload.
> I need to inform the users to uploading is in progress.
>
> I have search google ,and found megaupload , however the problem of
> megaupload is the filename is rubbish, i need the filename of uploaded
> file because the file is xml , need to convert data from xml to
> database.
>
> Anybody have any ideas ? Or have any another php upload progress
> monitor ?

[soapbox]

Can I respectfully suggest you just take php *OUT* of the equation?

You're talking about something on the CLIENT that needs to indicate
number of bytes SENT by the client out of total number of bytes the
client needs to SEND.

All the information involved is client-side.

Trying to hook PHP, on the server, into this is just plain daft.

Go bug the FireFox guys to give you callback hooks into the upload
process, or submit a patch to them.

Getting PHP involved in this equation makes zero sense -- You'd only
be generating a TON of HTTP traffic for PHP to tell the browser what
the browser already KNOWS.

[/soapbox]

PS
Or you could just train your users to actually look at the progress
meter in those browsers that already have one... :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Hi all ,

 Thanks for your inputs.
 I have tried the uber upload progress monitor , look good to me.

Thanks all
 - weetat

Richard Lynch wrote:
On Thu, June 15, 2006 4:48 am, weetat wrote:
   I was using PEAR:HTTP_Upload to upload file in php 4.3.2.
   Is ok , however i need to display some sort of progress monitor to
the user because some file is very large and took some times to
upload.
I need to inform the users to uploading is in progress.

I have search google ,and found megaupload , however the problem of
megaupload is the filename is rubbish, i need the filename of uploaded
file because the file is xml , need to convert data from xml to
database.

Anybody have any ideas ? Or have any another php upload progress
monitor ?

[soapbox]

Can I respectfully suggest you just take php *OUT* of the equation?

You're talking about something on the CLIENT that needs to indicate
number of bytes SENT by the client out of total number of bytes the
client needs to SEND.

All the information involved is client-side.

Trying to hook PHP, on the server, into this is just plain daft.

Go bug the FireFox guys to give you callback hooks into the upload
process, or submit a patch to them.

Getting PHP involved in this equation makes zero sense -- You'd only
be generating a TON of HTTP traffic for PHP to tell the browser what
the browser already KNOWS.

[/soapbox]

PS
Or you could just train your users to actually look at the progress
meter in those browsers that already have one... :-)


--- End Message ---
--- Begin Message ---
weetat wrote:

Hi all ,

  I was using PEAR:HTTP_Upload to upload file in php 4.3.2.
Is ok , however i need to display some sort of progress monitor to the user because some file is very large and took some times to upload.
I need to inform the users to uploading is in progress.

I have search google ,and found megaupload , however the problem of megaupload is the filename is rubbish, i need the filename of uploaded file because the file is xml , need to convert data from xml to database.

Anybody have any ideas ? Or have any another php upload progress monitor ?

Thanks

- weetat

PHP cannot do it. Other languajes, like jsp, is able to report that information.
I did it with Perl (CGI) and playing with some iframes.
Its a little complex and dirty.

--- End Message ---
--- Begin Message ---
        Try with
  preg_replace('/\d(?!(?>\d*)\))/X', '*', $phone)
wich would be a bit more efficient than
  preg_replace('/\d(?!\d*\))/X', '*', $phone)

Jeff Lewis wrote:
I have been working on a script to parse a CSV file and in the process I
clean out a lot of the garbage not needed but I am a bit stumped on one
aspect of this file. It's a list of over 3000 contacts and I'm trying to
mask a lot of the information with *.
So as I loop through this list I am checking the array elements as if I find
a phone number (555) 555-1212 (I was searching for the (555)) I want to
convert it to (555) ***-****
For fields not containing an area code, I wanted any text to be replaced by
an * except for the first and last letter in the element.
I'm stumped and was hoping that this may be something horribly simple I'm
overlooking that someone can point out for me.
--
Atentamente / Sincerely,
J. Rafael Salazar MagaƱa

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 3:04 am, Barry wrote:
> Richard Lynch schrieb:
>> and are all you can find from Google?
> O_o
>
>> Anybody?
> What?!?
>
>
> I for myself use this:
> header("Content-Type: application/force-download");
> header("Content-Type: application/octet-stream");
> header("Content-Type: application/download");
>
> Never had any problems with any browser.

You might as well delete the first two lines.  They don't do anything.

The last line "works" in the sense that no browser currently has any
pre-defined idea of what to *DO* with an "application/download"
because that's not a known MIME-type.

So the browser "punts" and presents a download window, because it has
NO IDEA what else to do.

Some goofball MADE UP application/download and "it worked"

If, however, tomorrow, some MS weenie decides that the Right Thing to
do with application/download is to store it in "My Documents" because
that's where everybody wants all the downloads to go, right?, then it
WILL NOT WORK tomorrow.

It's that simple.  IE 8 could decide application/download means "Put
it in My Documents" and you no longer have a download popup.

There is NOTHING to stop the MS engineers from doing that to you.

Nada.

BUUUUUT:

application/octet-stream is DEFINED in the HTTP SPEC to ALWAYS WORK.
Any browser that ever makes it not work is BADLY BROKEN.
They cannot change this tomorrow, without being non-HTTP-compliant,
and breaking backwards compatibility with a zillion Documented
Features.

So, use some goofball header that you make up, like:
header("Content-type: asdfqwerowiru/werouitohvosdfho");
and it will "work"

Or, realy on a DOCUMENTED FEATURE and use:
header("Content-type: application/octet-stream");

Your choice, really, though obviously I have a strong opinion on which
one is the Right Way to do it.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 7:41 am, Chris Shiflett wrote:
> Regardless, I think Content-Disposition is the header you need, not
> Content-Type.

It is possible that all "modern" browsers have given in to whichever
johnny-come-lately 'standard' made up the Content-disposition header.

I know for sure it did not work in some browsers back in the day.

I'm only saying that

Content-type: application/octet-stream

has worked from the very beginning of time, and is a Documented
Feature, and is incredibly unlikely to ever not work.

If you don't care about ancient, niche, or otherwise "odd" browsers,
fine.

If you want something that works for EVERY browser for the beginning
of time, and will almost-for-sure never not wor, unless the spec
changes in a non-backwards-compatible way, breaking a zillion web
applications...

You choose your headers, and you take your chances.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Thu, June 15, 2006 10:17 am, Jon Anderson wrote:
> Richard Lynch wrote:
>> Can any experts on this list explain to me why, despite the
>> 1,000,000
>> places that application/octet-stream is documented to work, and has
>> always worked, since Mosaic 1.0 days, people manage to find these
>> goofball Content-type: headers that are supposed to work, but only
>> work in a handful of browsers, and then they write tutorials as if
>> it's the Right Way, and then those tutorials get past alleged
>> Editors,
>> and are all you can find from Google?
>>
>> Anybody?
> Well, I can't vouch for any goofballs, their editors, nor google, but
> unfortunately sometimes an alternative to application/octet-stream has
> to be used to work around brokenness in certain versions of IE...We
> used
> octet-stream, and had a small portion of users complaining because
> they
> couldn't open the file that was downloaded - "I can't open
> download.php", hence the workaround.

But they downloaded it.

They HAVE the data, it's just got a filename they don't know what to
do with.

If they just change the extension to whatever it should be, it would
be fine.

> - We can't use download.php?/filename.ext - (long story, but suffice
> it
> to say that it can't be done for non-technical reasons.)

Well, then, you've just eliminated a correct technical solution for
non-technical reasons...

I cannot do much about that...

Actually, if you REALLY want to be browser-compliant back to the stone
age, and througout the dreaded 3.x and 4.x series, you would need to
get the URL to be just:
http://example.com/script_that_looks_like_dirname/filename.ext

That odd-looking dirname is a PHP script.

URL juggling with mod_rewrite ForceType and $_SERVER['PATH_INFO'] is
the tech.

The browser then CANNOT screw up beause it "looks" like a static URL.

> - IE doesn't take the Content-Disposition in some cases unless you use
> a
> different content-type.
>
> Our code basically does this:
>
> if (IE) {
>     use wrong content type;
>     if (IE 5.5) {
>        use broken content disposition;
>     } else {
>        use normal content disposition;
>     }
> } else {
>     do things in a standard way;
> }

My code basically looks like this:
header("Content-type: application/octet-stream");

Though, admittedly, the 3 lines in .htaccess should "count"

And, if you want input parameters in the URL instead of GET (which
will mess up FDF files) then there's another 20 lines to parse
$_SERVER['PATH_INFO'] into an array, just like $_GET and $_POST, only
not.

But then, that code is in an include file and gets re-used for a lot
of different rich media (images, PDF, Ming flash movies, etc) so it's
got a decent re-use factor.

Maybe I'm just re-using code from 5 years ago that could be replaced
by the browser-detecting (assuming the user-agent doesn't lie) and
using some new-fangled headers...

Or I could just keep using the code that cannot break.  Yeah, I like
that.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
It is possible that all "modern" browsers have given
in to whichever johnny-come-lately 'standard' made
up the Content-disposition header.

The original RFC for it is dated June 1995, so it's not too recent. There are plenty of useful aspects of HTTP not defined in RFC 2616.

Content-type: application/octet-stream

There's no reason you can't use both.

Chris

--- End Message ---
--- Begin Message ---
Hello,

on 06/15/2006 11:56 AM Brad Bonkoski said the following:
> Hello All,
> I am using PERL to generate an XML file from a database query.  no
> problems there.
> I then try to use curl to send it to an upload script.
> Essentially the command line looks like this: curl -H
> 'Content-Type:text/xml' -d file.xml server/up.php
> for my up.php I am just trying to dump stuff out, like the POST and
> FILES arrays
> Both those arrays are empty.
> 
> Any thoughts on how to debug this, and/or suggestions for handling this?

You do not need to use a separate program to upload files with forms.
You can use PHP with socket connections.

Take a look at this pure PHP HTTP client class that lets you post files
for upload. You can just point it to a local file or some dynamically
generated data. It lets you choose the the file name in case you do not
want to use the local file name. Take a look at the test_http_post.php
example:

http://www.phpclasses.org/httpclient


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
Hi,

I have several websites that are using a common set of pages (to reduce
maintenance, development and upgrading) and use configuration files to give
the customer the feeling that it is their own unique site. The customers are
all universities and use the sites to manage digitisation and copyright
permission processes. These sites are all hosted om my company server.

I would like them to be able to see whether a PDF file hosted by their
universities is available or not.

Using file_exists($url) won't work because the actual PDFs should be sitting
behind the universities' firewalls.

I think that something working on the client-side, such as JavaScript might
work, because it would be able to look from the client's machine to the PDF,
both of which should be behind the firewall to the PDF. However, I haven't
been able to find any js that looks like it will do that for me.

Does anyone have any constructive suggestions?

MTIA

George in Oxford

--- End Message ---
--- Begin Message ---
Hi all ,

I have a <SELECT> for country in the php file . I would like to load the country and city belong to the country dynamically from the database.

Anyone have ideas how to do it ?

Thanks
- weetat

--- End Message ---

Reply via email to