php-general Digest 15 Jul 2004 16:28:32 -0000 Issue 2878
Topics (messages 190559 through 190602):
Re: upload an image and store it in mysql
190559 by: Five
190561 by: Ed Lazor
190569 by: raditha dissanayake
[Newbie Guide] For the benefit of new members
190560 by: Ma Siva Kumar
Re: PHP5 Windows not built with Soap Enabled?
190562 by: Sean Malloy
190582 by: Vincent Jansen
Re: Dynamic to Static
190563 by: Edwards Jim
190565 by: Jason Barnett
190571 by: raditha dissanayake
190576 by: Mirek Novak
190592 by: Robert Sossomon
Re: Compile Php5: --with-mysql and --with-mysqli
190564 by: Jacob Friis Larsen
190573 by: Marek Kilimajer
190580 by: Jacob Friis Larsen
Re: [Q] PHP 101 -- How to check for session existence?
190566 by: Jason Barnett
190568 by: Ciprian Constantinescu
Re: New object model
190567 by: Jason Barnett
190574 by: Marek Kilimajer
Re: Site Planning
190570 by: Jason Barnett
190575 by: Justin French
Re: php vs. cgi app
190572 by: Jason Barnett
190577 by: Ed Lazor
190578 by: Jason Wong
MIME files decoding
190579 by: C.F. Scheidecker Antunes
190581 by: Aidan Lister
Regular Expressions
190583 by: Arik Raffael Funke
190584 by: Marek Kilimajer
190585 by: Matt M.
190586 by: Arik Raffael Funke
190587 by: Tim Van Wassenhove
190588 by: Jason Wong
Log all GET AND POST?
190589 by: Robert Sossomon
190590 by: Jay Blanchard
190594 by: James E Hicks III
190598 by: raditha dissanayake
PHP5 release HTTP Authentication not working on FreeBSD.
190591 by: William Bailey
problem including images in safe_mode
190593 by: Frank Holtschke
190596 by: Jason Wong
190599 by: Frank Holtschke
including external C header files and libraries
190595 by: Jeremy Booker
File locking in PHP???
190597 by: Scott Fletcher
190600 by: Matt M.
190601 by: Scott Fletcher
190602 by: Scott Fletcher
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 ---
"John W. Holmes" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Five wrote:
> > I have php code that takes text input from a webpage and and stores it in a mysql
> > data base.
> > I tried uploading small images (jpg) using basically the same syntax but they
> > don't make it into the data base.
> > Does anyone know of a simple tutorial that shows how to do this?
>
> although I'm against storing files in databases...
>
> $file =
> mysql_real_escape_string(file_get_contents($_FILES['yourfile']['tmp_name']));
> $query = "INSERT INTO yourtable (imgdata) VALUES ('$file')";
>
> --
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> php|architect: The Magazine for PHP Professionals � www.phparch.com
Thanks, that seems to work. Although trying to retrieve them and show them in a
browser shows characters / symbols instead. This
kind of stuff:
j�w4�ܭq�H�QI'[EMAIL PROTECTED] `�*[#�j �q6є]Q.b ���(Y�:9�-"Ҫ(K\�'��
���EbX��W(�e
9�ƛ�p�EX�a��l�˵m8=��{��x�f� ��� L��y���e�(���5� ��PP��3�a� ���o X��D
~���J�
�VиܶF&�7��� c�[3b䱄C�&E���
--- End Message ---
--- Begin Message ---
You're seeing raw data and need to specify the mime type with headers. Search the
mailing list archive, there's a few example scripts in there. Just keep in mine that
you need to create a separate script that handles the display of images.
> Thanks, that seems to work. Although trying to retrieve them and show them
> in a browser shows characters / symbols instead. This
> kind of stuff:
>
> jÂw4ÃÃÂqÃHÃQI'[EMAIL PROTECTED] `Ã*[#âj Âq6Ãâ]Q.b
> ÂÅÃÂ(YÅ:9Â-"ÃÂ(K\Â'ÂÃ
> ÅÃÃEbXÃÃÂW(Ãe
> 9ÂÃâÂpÃÂEXÅaÃÃlÃÃÂm8=ËÂ{ÂÃxÂfà ÂÃÃ
> LÃÃyÂÂÃeÃÂÂ(ÂÅÃ5Å ÂÂPPââ3âa â
> ÃÃâo XÅÃD ~ÂÃÃJÂ
> ÃVÃÂÃÂF&Â7ÂÅÂ cÃ[3bÃÂâCÂ&EÃÃÃ
--- End Message ---
--- Begin Message ---
I have php code that takes text input from a webpage and and stores it in a mysql data base.
I tried uploading small images (jpg) using basically the same syntax but they don't make it into the data base.
Does anyone know of a simple tutorial that shows how to do this?
although I'm against storing files in databases...
$file =
mysql_real_escape_string(file_get_contents($_FILES['yourfile']['tmp_name']));
$query = "INSERT INTO yourtable (imgdata) VALUES ('$file')";
Thanks, that seems to work. Although trying to retrieve them and show them in a
browser shows characters / symbols instead. This
kind of stuff:
j?w4ëÜqÈHæQI'[EMAIL PROTECTED] `Ñ*[#‰j ¥q6Ñ”]Q.b ?Œâ¶(YŒ:9£-"Òª(K\¯'½È ŽÛÃEbXÊê£W(Ìe
9?Æ›¹pã´EXŽaâÑlÑ˵m8=˜±{?ãx´fî ©ÜÎ Lãùy?§ùeñ©±(£Žâ5Œ ¢µPP€‹3›aª —Ãç‰o XŠÓD ~?ûüJ¢
ÜVиܶF&·7´š© cæ[3b䱄C°&EôÐî
Another reason for not storing images in a database - you need to spit
out the correct set of headers before you send the actual image data.
--
Raditha Dissanayake.
---------------------------------------------
http://www.raditha.com/megaupload/upload.php
Sneak past the PHP file upload limits.
--- End Message ---
--- Begin Message ---
=======================================
Please feel free to add more points and send
to the list.
=======================================
1. If you have any queries/problems about PHP
try http://www.php.net/manual/en first. You
can download a copy and use it offline also.
Please also try
http://www.php.net/manual/faq.php
for answers to frequently answered questions
about PHP (added by Christophe Chisogne).
2. Try http://www.google.com next. Searching
for "php YOUR QUERY" may fetch you relevant
information within the first 10 results.
3. There is a searchable archive of the
mailing list discussion at
http://phparch.com/mailinglists. Many of the
common topics are discussed repeatedly, and
you may get answer to your query from the
earlier discussions.
For example: One of the repeatedly discussed
question in the list is "Best PHP editor".
Everyone has his/her favourite editor.
You can get all the opinions by going through
the list archives. If you want a chosen list
try this link :
http://www.thelinuxconsultancy.co.uk/phpeditors/
(contributed by Christophe Chisogne).
4. Not sure if PHP is working or you want
find out what extensions are available to
you?
Just put the following code into a file with
a .php extension and access it through your
webserver:
<?php
phpinfo();
?>
If PHP is installed you will see a page with
a lot of information on it. If PHP is not
installed (or not working correctly) your
browser will try to download the file.
(contributed by Teren and reworded by Chris W
Parker)
5. If you are stuck with a script and do not
understand what is wrong, instead of posting
the whole script, try doing some research
yourself. One useful trick is to print
the variable/sql query using print or echo
command and check whether you get what you
expected.
After diagnosing the problem, send the
details of your efforts (following steps 1,
2 & 3) and ask for help.
6. PHP is a server side scripting language.
Whatever processing PHP does takes place
BEFORE the output reaches the client.
Therefore, it is not possible to access
users' computer related information (OS,
screen size etc) using PHP. Nor can you
modify any the user side settings. You need
to go for JavaScript and ask the question in
a JavaScript list.
On the other hand, you can access the
information that is SENT by the user's
browser when a client requests a page from
your server. You can find details about
browser, OS etc as reported by
this request. - contributed by Wouter van
Vliet and reworded by Chris W Parker.
7. Provide a clear descriptive subject line.
Avoid general subjects like "Help!!", "A
Question" etc. Especially avoid blank
subjects.
8. When you want to start a new topic, open a
new mail composer and enter the mailing list
address [EMAIL PROTECTED] instead of
replying to an existing thread and replacing
the subject and body with your message.
9. It's always a good idea to post back to
the list once you've solved your problem.
People usually add [SOLVED] to the subject
line of their email when posting solutions.
By posting your solution you're helping the
next person with the same question.
[contribued by Chris W Parker]
10. Ask smart questions
http://catb.org/~esr/faqs/smart-questions.html
[contributed by Jay Blanchard)
11. Do not send your email to the list with
attachments. If you don't have a place to
upload your code, try the many pastebin
websites (such as www.pastebin.com).
[contributed by Burhan Khalid]
Hope you have a good time programming with
PHP.
--
Integrated Management Tools for leather
industry
----------------------------------
http://www.leatherlink.net
Ma Siva Kumar,
BSG LeatherLink (P) Ltd,
Chennai - 600106
--- End Message ---
--- Begin Message ---
> checking the output of phpinfo() for the 5.0.0 binary from www.php.net, it
> would seem there is no soap support built in at all.
>
> Or have I just not woken up today?
I win the "You're a Dumb Ass" award for the day.
"The SOAP extension isn't activated by default (PHP5 RC1). Just add
"extension=php_soap.dll" to the php.ini and don't forget to set the
extension_dir properly (in most cases "c:\php\ext")."
(I swear I checked the extensions folder. I don't know why I didn't see it
before...)
--- End Message ---
--- Begin Message ---
Did you adjust your php.ini file?
> -----Original Message-----
> From: Sean Malloy [mailto:[EMAIL PROTECTED]
> Sent: donderdag 15 juli 2004 3:50
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP5 Windows not built with Soap Enabled?
>
>
> Am I the only one experiencing this:
>
> Fatal error: Class 'SoapClient' not found
>
> checking the output of phpinfo() for the 5.0.0 binary from
www.php.net, it would seem there is no soap support built in at all.
Or have I just not woken up today?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello Ed,
We have used a combination of the following scripts on our site:
/jim
if ((filemtime("cache/$sidid") + 60) > time()) {
$cachefile = fopen("cache/$sidid","r");
fpassthru($cachefile);
exit();
}
// start buffering the output
ob_start();
// output format - either "www" or "file"
$output = "outputfile.php";
$data = ob_get_contents();
$fp = fopen ("inputfile.inc", "w");
fwrite($fp, $data);
fclose($fp);
ob_end_clean();
echo "finished";
-----Original Message-----
From: Ed Lazor [mailto:[EMAIL PROTECTED]
Sent: den 15 juli 2004 06:20
To: [EMAIL PROTECTED]
Subject: [PHP] Dynamic to Static
Is anyone taking a dynamic PHP / MySQL site and storing or cacheing it
statically in order for pages to display more quickly when visitors access
the site? If so, what solutions are you using to achieve this?
Thanks,
Ed
--- End Message ---
--- Begin Message ---
Ed Lazor wrote:
Is anyone taking a dynamic PHP / MySQL site and storing or cacheing it
statically in order for pages to display more quickly when visitors access
the site? If so, what solutions are you using to achieve this?
Thanks,
Ed
Hey Ed, there are a couple of ways that you can do it depending on your
needs. Probably the easiest way to do it is to generate the entire page
once and cache it for some period of time (1 hour?) and then serve that
page until you determine it should expire.
OR
You could create a static part of a page and a dynamic part of a page.
HTML works best for the static part (obviously :) and then you just get
the php code you need for the dynamic. If this is your choice, then
you'll probably want to cache MySQL query results and as much of the
personalized user information as possible - dbm files can work well for
this.
OR
If there isn't much personal information (but a lot of users... you DO
have a lot of users right? ;) you can be really stingy and store some
user data in a cookie. Usual rules for cookies apply here, but
basically if you have very little personalized info needed for every
page then this can be more efficient than db calls.
OR
Try using one of the software packages out there that cache php byte
code (especially if you have a lot of includes). If you absolutely
demand dynamic generation and want a performance boost, Zend can help
you out a lot in this department.
OR
Some other solution someone more clever than I has come up with :)
--- End Message ---
--- Begin Message ---
Ed Lazor wrote:
Is anyone taking a dynamic PHP / MySQL site and storing or cacheing it
statically in order for pages to display more quickly when visitors access
the site? If so, what solutions are you using to achieve this?
The best example of this that I have seen is in the mediawiki software -
the software that powers the wikipedia.
For smaller sites (i appologise if yours is a huge site) all that hard
work is not required. Just install turck MMCache if you are really
worried about speed.
--
Raditha Dissanayake.
---------------------------------------------
http://www.raditha.com/megaupload/upload.php
Sneak past the PHP file upload limits.
--- End Message ---
--- Begin Message ---
Hi,
Ed Lazor wrote:
Is anyone taking a dynamic PHP / MySQL site and storing or cacheing it
statically in order for pages to display more quickly when visitors access
the site? If so, what solutions are you using to achieve this?
Thanks,
Ed
I'm using two-way or two-step caching - I'll try to describe it ;)
conditions:
- wrote special class for cache handling, updating
- using smarty
- using turck mmcache
1. step
- as the data I'm passing to smarty are only array, I've decided to store
this pre-generated array in a file*.
- data are refreshed not periodically but only when changed or if they are
missing*
- in the scrip, where I'm displaying those data, the file is only included
*this is done by my caching class
2. step
- as I'm using turck mmcache, data file is precompiled into bytecode and held
in
shared memory.
I've got HUGE improvement in speed and from-time-to-time server loads disappeared.
From 0.1s per script I've got to approx 0.005s per script, ofcourse it depends on some
other conditions, but generally improvement was huge.
--
Mirek Novak
jabberID: [EMAIL PROTECTED]
ICQ: 119499448
--- End Message ---
--- Begin Message ---
>Is anyone taking a dynamic PHP / MySQL site and storing or cacheing it
statically in
>order for pages to display more quickly when visitors access the site?
If so, what
>solutions are you using to achieve this?
I looked at doing it, wrote a single PHP-page that when I accessed would
make static pages for me (numbering in the thousands), but it was all
for nought as the pieces of code I included in the web pages made for
not being able to get a PHP-session variable and hindering my cart
process. Maybe I could change the code in some way to get the correct
information where I need it, but at this time the functional way to do
it was with leaving the pages dynamic.
That being said, if all you want to do is spit out numerous pages (based
off MySQL data) and put them on the web for people to look at, I would
be happy to shoot you my PHP page to work it out.
Robert
--- End Message ---
--- Begin Message ---
Curt Zirzow wrote:
* Thus wrote Jacob Friis Larsen:
How do I install Php5 with both --with-mysql and --with-mysqli?
1. Follow instructions at http://php.net/mysqli.
Is this correct: "--with-mysqli=/usr/bin/mysql_config"?
(This works: ./configure --with-mysqli=/usr/bin/mysql_config --with-apxs2)
2. Follow instructions at http://php.net/mysql, using the path
to your mysql4.1 library
Is this correct: "--with-mysql=/usr"?
If not, how can I find out?
3. Tweak your my.cnf so the mysqlclient look at the right places.
What should I tweak?
MySQL is the original RPM from MySQL. Version 4.1.3-beta.
Sorry, I think I need more help.
I've read this: "If you would like to install the mysql extension along
with the mysqli extension you have to use the same client library to
avoid any conflicts.", but I do not understand the meaning of it. There
is only one MySQL installation on the server.
This is my configure, which fails:
./configure --disable-all --with-mysqli=/usr/bin/mysql_config
--with-mysql=/usr --with-apxs2
Thanks,
Jacob
--- End Message ---
--- Begin Message ---
Jacob Friis Larsen wrote:
Curt Zirzow wrote:
* Thus wrote Jacob Friis Larsen:
How do I install Php5 with both --with-mysql and --with-mysqli?
1. Follow instructions at http://php.net/mysqli.
Is this correct: "--with-mysqli=/usr/bin/mysql_config"?
(This works: ./configure --with-mysqli=/usr/bin/mysql_config --with-apxs2)
2. Follow instructions at http://php.net/mysql, using the path to
your mysql4.1 library
Is this correct: "--with-mysql=/usr"?
If not, how can I find out?
execute /usr/bin/mysql_config --include. It's the path without
include/mysql. Also make sure you don't have multiple libraries
installed, you should install MySQL-shared-compat*.rpm
3. Tweak your my.cnf so the mysqlclient look at the right places.
What should I tweak?
MySQL is the original RPM from MySQL. Version 4.1.3-beta.
Sorry, I think I need more help.
I've read this: "If you would like to install the mysql extension along
with the mysqli extension you have to use the same client library to
avoid any conflicts.", but I do not understand the meaning of it. There
is only one MySQL installation on the server.
This is my configure, which fails:
./configure --disable-all --with-mysqli=/usr/bin/mysql_config
--with-mysql=/usr --with-apxs2
--- End Message ---
--- Begin Message ---
execute /usr/bin/mysql_config --include. It's the path without
include/mysql.
In that case my configure is correct:
./configure --disable-all --with-mysqli=/usr/bin/mysql_config
--with-mysql=/usr --with-apxs2
Also make sure you don't have multiple libraries
installed, you should install MySQL-shared-compat*.rpm
I have installed MySQL-shared-compat-4.1.3-0.i386.rpm, but I still get
errors.
thanks,
Jacob
--- End Message ---
--- Begin Message ---
Hey Michael, I think you really only need to check the $_SESSION array,
not necessarily each index.
if (!isset($_SESSION)) {
// login
header('Location: ' . MEMBER_LOGIN_PAGE);
} else {
// session exists
}
However, if you want to have non-empty values for your session variables
you should use:
if (empty($_SESSION['username'] || empty($_SESSION['session_id']) {
// session indexes username and / or session_id are empty
header('Location: ' . MEMBER_LOGIN_PAGE);
}
There is a fine difference between isset() and empty(). Check the
online manual or this newsgroup for further discussion.
--- End Message ---
--- Begin Message ---
I think it would be better to use Apache facility of authentication through
Mysq
l
"Michael T. Peterson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> To protect certain web pages on my site, I am using the following code
> inserted at the very beginning (top) of the page:
>
> <?php
> include_once( 'init.php');
> if( isset( $HTTP_SESSION_VARS['session_id'] ) == FALSE ||
> isset( $HTTP_SESSION_VARS['username'] ) == FALSE ){
> header( 'Location: '.MEMBER_LOGIN_PAGE );
> }
> ?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> ... Dreamweaver template code here...
> </html>
>
> Is this a recommended way of doing this?
>
> Next, to initialize the session, a login page posts the username -
password
> information to a PHP script, check_login.php. The login info is checked
> against a database and, if all is kosher, a new session is created and the
> user is dispatched to the site's home page. Here's the relevant code:
>
> <?php
> include_once( 'init.php');
> ...
> $username = trim($HTTP_POST_VARS['username']);
> $password = trim($HTTP_POST_VARS['password']);
>
> ... if username and password check out, initialize a session...
>
> $HTTP_SESSION_VARS['username'] = $username;
> $HTTP_SESSION_VARS['session_id'] = crypt( $password );
>
> header( 'Location: '.SITE_HOME_PAGE );
> ...
> ?>
>
> Does this make sense? Am I missing something? Any review, advice, etc.,
> would be much appreciated.
>
> Cheers,
>
> Michael
--- End Message ---
--- Begin Message ---
Troy S wrote:
Is there an ini-file setting so that objects are
passed by value as in PHP 4? If so, how long is this
likely to be supported?
Thanks,
Troy
Although you can turn on zend engine 1 compatibility, if you intend to
distribute your code you cannot expect this on most servers. Another
way to pass by value is to use the __clone method.
function test($orig, $clone) {
$orig->x = 'I am the original.';
$clone->x = 'I am a clone.';
print_r($orig);
// should be different since this is a copy, not a reference
print_r($clone);
}
class foo {}
$orig = new foo();
test($orig, $orig->__clone());
--- End Message ---
--- Begin Message ---
Jason Barnett wrote:
Although you can turn on zend engine 1 compatibility, if you intend to
distribute your code you cannot expect this on most servers. Another
way to pass by value is to use the __clone method.
function test($orig, $clone) {
$orig->x = 'I am the original.';
$clone->x = 'I am a clone.';
print_r($orig);
// should be different since this is a copy, not a reference
print_r($clone);
}
class foo {}
$orig = new foo();
test($orig, $orig->__clone());
Fatal error: Cannot call __clone() method on objects - use 'clone $obj'
instead... Should be:
test($orig, clone($orig));
--- End Message ---
--- Begin Message ---
Ee wrote:
Can anyone point me to a good article about site planning before coding.
I searched the net but couldn't find a good one?
This question is too broad - as usual it depends on your needs. Ask a
more specific question, or hire someone to plan out your site for you.
--- End Message ---
--- Begin Message ---
On 15/07/2004, at 6:15 AM, EE wrote:
Can anyone point me to a good article about site planning before
coding.
I searched the net but couldn't find a good one?
Really this is far too broad to be answered here, and unless you're
talking specifically about PHP web application development, it's also
quite off-topic.
If you're talking about diagrams and flow charts, I highly recommend
Jesse James Garret's Visual Vocabulary:
http://jjg.net/ia/visvocab/
If you're talking specifically about PHP application frameworks, then
you'll need to a LOT of reading of the many different frameworks and
methodologies out there (FuseBox, Model-View-Controller, etc), and
formulate your own opinions, but the reality is I've been designing and
developing web apps for over 4 years, and my own framework/methods are
still in constant development.
A lot of them are mentioned on phpPatterns
<http://phppatterns.com/index.php/link/category/34/>, and you can learn
a LOT by getting involved in (or studying the source of) a mature open
source project (I'm currently spending quite a bit of time in
Texpattern's code <http://www.textpattern.com>.
Ask a more detailed question, and you'll get a more detailed answer.
---
Justin French
http://indent.com.au
--- End Message ---
--- Begin Message ---
Bruce, you need to start new threads when you ask a new question... a
lot of people don't bother to check out a thread that's already got
responses, and it really makes more logical sense to start a new one
anyway (original post is below my response)...
When you say cgi vs. php, I'm going to assume you mean cgi versus apache
module (correct me if I misunderstand). To be honest I don't know
enough about the internals of the apache module to tell you why it's
better for an apache server (would love it if someone could explain!).
What I do know I've gathered from PHP's site... check these out:
http://www.php.net/install.commandline
http://us3.php.net/manual/en/security.cgi-bin.php
Jason
[original post]
hi..
a really general/basic question... what is the difference between a "cgi"
app and a php app.. does it really come down to where the app is being run
from..
i mean within apache, if i specify that php/perl/etc... app resides at a
given location, and that files with a certain extension are to be handled by
the perl/php/etc app, then i can handle the processing of the file by the
interpreter anywhere within my site that i grant access to. is there
anything/any reason to have a "cgi-bin" portion of my app, other than good
design practice...
clarification would be useful!!!
thanks..
-bruce
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> When you say cgi vs. php, I'm going to assume you mean cgi versus apache
> module (correct me if I misunderstand). To be honest I don't know
> enough about the internals of the apache module to tell you why it's
> better for an apache server (would love it if someone could explain!).
PHP loads as an Apache module at startup and remains in memory, ready to
process files. Running PHP as a cgi means that Apache has to load and run
PHP each time a PHP file is processed.
Basically, there's a lot of extra work in running PHP as a cgi. There are
some benefits to having the cgi available though. For example, if you're at
a unix prompt and need to process a file. Or, more commonly, if you want to
execute scripts in cronjobs.
-Ed
--- End Message ---
--- Begin Message ---
On Thursday 15 July 2004 16:02, Ed Lazor wrote:
> There are
> some benefits to having the cgi available though. For example, if you're
> at a unix prompt and need to process a file. Or, more commonly, if you
> want to execute scripts in cronjobs.
For these situations you would be better off using the CLI version of PHP.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Sometimes when you look into his eyes you get the feeling that someone
else is driving.
-- David Letterman
*/
--- End Message ---
--- Begin Message ---
Hello all,
In order to use pear mimedecode.php I have a few questions that were not
answered by the documentation.
I have emails that have .zip, .pdf, .txt and .csv files.
Some emails have more than one attachment.
I would like to have a php script to fetch these emails and save only
those with .zip , .txt and .csv deleting everything else.
Can anyone point me how to use mimedecode so that I can keep the
original filename of the attachment. How can I obtain the file name?
Thanks in advance.
--- End Message ---
--- Begin Message ---
Hi Scheidecker,
Try posting to [EMAIL PROTECTED], the author will be able to help
you with your question.
"C.F. Scheidecker Antunes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello all,
>
> In order to use pear mimedecode.php I have a few questions that were not
> answered by the documentation.
>
> I have emails that have .zip, .pdf, .txt and .csv files.
>
> Some emails have more than one attachment.
>
> I would like to have a php script to fetch these emails and save only
> those with .zip , .txt and .csv deleting everything else.
>
> Can anyone point me how to use mimedecode so that I can keep the
> original filename of the attachment. How can I obtain the file name?
>
> Thanks in advance.
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello together,
I am havin trouble with php regular expressions. I would like to
implement following pattern "Last Name:\s*(.*)\n".
- From following text,
Name: James
Last Name: Jason
Street: abc
I get just 'Jason'. But what I currently get is:
Jason
Street: abc
Obviously the new-line is missed. Any thoughts on this?
sample code:
ereg("Last Name:\s*(.*)\n", $strInput, $regs)
echo $regs[1];
Thanks for the help!
Cheers,
Arik
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFA9ns4//PXyz2NiW8RAuLDAJ0eBoCsJvT919/9xoVdk+BUkc8pegCeJ6O0
PxeXTxOwxr4WF639fZpDFYs=
=3BQA
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
Arik Raffael Funke wrote:
Hello together,
I am havin trouble with php regular expressions. I would like to
implement following pattern "Last Name:\s*(.*)\n".
- From following text,
Name: James
Last Name: Jason
Street: abc
I get just 'Jason'. But what I currently get is:
Jason
Street: abc
Obviously the new-line is missed. Any thoughts on this?
sample code:
ereg("Last Name:\s*(.*)\n", $strInput, $regs)
echo $regs[1];
Thanks for the help!
Cheers,
Arik
Donno about regular expressions but with perl compatible you can use:
preg_match('/Last Name:\s*(.*)\n/', $inputStr, $regs);
--- End Message ---
--- Begin Message ---
> Obviously the new-line is missed. Any thoughts on this?
>
> sample code:
> ereg("Last Name:\s*(.*)\n", $strInput, $regs)
> echo $regs[1];
try this:
ereg("Last Name:\s*(.*[^\n])", $strInput, $regs);
echo $regs[1];
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, 15 Jul 2004 08:02:13 -0500
"Matt M." <[EMAIL PROTECTED]> wrote:
> > Obviously the new-line is missed. Any thoughts on this?
> >
> > sample code:
> > ereg("Last Name:\s*(.*)\n", $strInput, $regs)
> > echo $regs[1];
>
> try this:
>
> ereg("Last Name:\s*(.*[^\n])", $strInput, $regs);
> echo $regs[1];
>
Thanks for the quick help.
Both ways,
preg_match('/Last Name:\s*(.*)\n/', $inputStr, $regs);
and
ereg("Last Name:\s*(.*[^\n])", $strInput, $regs);
work fine.
However if I have,
Last Name:
Street: Teststreet
(no entry after last name)
Both search strings return me:
- ----
Street: Teststreet
- ----
Also why doesn't "Last Name:\s*(.*)$" work, and neither "^Last
Name:\s*(.*)". Both strings are not found at all - that's why I thought
the php implementation might treat new lines in a strange way.
Can anybody explain these effects to me?
Cheers,
Arik
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFA9oN1//PXyz2NiW8RAmCQAJ9wRDxc8YDyfU+4EoNeRsqMKJDPBQCgsMvv
7cpFD6cYZuckqGdY+1Gtqi8=
=Hi/P
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
In article <[EMAIL PROTECTED]>, Arik Raffael Funke wrote:
> implement following pattern "Last Name:\s*(.*)\n".
> I get just 'Jason'. But what I currently get is:
> Jason
> Street: abc
This is behaviour because (.*) is greedy.
As you noticed, it matched "Jason \nStreet:abc"
/Last Name:\s+(.*?)\n/
--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
--- End Message ---
--- Begin Message ---
On Thursday 15 July 2004 21:15, Arik Raffael Funke wrote:
>
> However if I have,
> Last Name:
> Street: Teststreet
> (no entry after last name)
>
> Both search strings return me:
> ----
>
> Street: Teststreet
> ----
>
> Also why doesn't "Last Name:\s*(.*)$" work, and neither "^Last
> Name:\s*(.*)". Both strings are not found at all - that's why I thought
> the php implementation might treat new lines in a strange way.
preg_match('|^Last Name:(.*)$|m', $haystack, $matches);
should work.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Someone is speaking well of you.
How unusual!
*/
--- End Message ---
--- Begin Message ---
I was wondering if anyone knew of a way to log all GET and POST
information being passed to a log file?
Thanks,
Robert
--- End Message ---
--- Begin Message ---
[snip]
I was wondering if anyone knew of a way to log all GET and POST
information being passed to a log file?
[/snip]
Yes. Create a log file. Pass all GET and POST information to it. Over
and over.
--- End Message ---
--- Begin Message ---
On Thursday 15 July 2004 09:58 am, Robert Sossomon wrote:
> I was wondering if anyone knew of a way to log all GET and POST
> information being passed to a log file?
>
> Thanks,
> Robert
$DEBUG_DATA = $_SERVER['PHP_SELF']."\n";
while (list ($key, $val) = each ($_REQUEST)) {
if (is_array($_REQUEST[$key])){
while (list ($ar_key, $ar_val) = each ($_REQUEST[$key])) {
$DEBUG_DATA .= "$key [ $ar_key ] => $ar_val\n";
}
} else {
$DEBUG_DATA .= "$key => $val\n";
}
}
mysql_select_db("HISTORY");
$query = "insert into BIG_BROTHER
values (
'".$_SESSION['user_ID']."',
".time().",
'$DEBUG_DATA')";
mysql_query($query);
reset($_REQUEST);
--- End Message ---
--- Begin Message ---
Robert Sossomon wrote:
I was wondering if anyone knew of a way to log all GET and POST
information being passed to a log file?
The GET stuff is already in your apache log file. The POST stuf you
probably don't want to log because it can be rather huge if you are
dealing with things like file uploads. Jame's suggestion seems pretty
good especially because you cannot get the raw post data for 'known'
content types with PHP.
--
Raditha Dissanayake.
---------------------------------------------
http://www.raditha.com/megaupload/upload.php
Sneak past the PHP file upload limits.
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Guys,
I've just upgraded from 5.0 rc3 to 5.0 release on freeBSD (using the
ports) and now find that HTTP Authentication dosent work.
Here is the test script that i am using:
<?php
~ error_reporting(E_ALL);
~ ini_set('display_errors', true);
~ if (! (isset($_SERVER['PHP_AUTH_USER']) ||
isset($_SERVER['PHP_AUTH_PW']) )) {
~ header('WWW-Authenticate: Basic realm="My Realm"');
~ header('HTTP/1.0 401 Unauthorized');
~ echo 'Text to send if user hits Cancel button';
~ exit;
~ } else {
~ echo "<p>Hello '{$_SERVER['PHP_AUTH_USER']}'.</p>";
~ echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
~ }
?>
And here is the output that i get:
Notice: Undefined index: PHP_AUTH_USER in test.php on line 10
Hello ''.
You entered pass as your password.
As you can see PHP_AUTH_USER is on longer being set. Does anybody else
have this issue or know of a fix?
- --
Regards,
William Bailey.
Pro-Net Internet Services Ltd.
http://www.pro-net.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFA9o3ZzSfrYDJMXmERAmZqAKCunk+xl2w+RRIKOvbDTQEWjXbGCgCgxXsw
DknafWhfiwLTYrusTzHl0gE=
=IMNL
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
Hall all,
i have sometimes problems to include images. the reason are substrings
like <? in the image.
in that case the php-parser tries to parse the string and returns the error:
parse error, unexpected ',' in
unforunatly there in no other way to include the image, cause the server
runs in safe_mode and
the image is located in the safe_mode_include_dir. therefore readfile
and things like that wont work.
Any suggestions how to protect an including file for getting parsed?
Thanks in advance.
--- End Message ---
--- Begin Message ---
On Thursday 15 July 2004 19:52, Frank Holtschke wrote:
> i have sometimes problems to include images. the reason are substrings
> like <? in the image.
> in that case the php-parser tries to parse the string and returns the
> error:
>
> parse error, unexpected ',' in
>
> unforunatly there in no other way to include the image, cause the server
> runs in safe_mode and
> the image is located in the safe_mode_include_dir. therefore readfile
> and things like that wont work.
> Any suggestions how to protect an including file for getting parsed?
Even if you could prevent an included file from being parsed, I can't see how
it would help you as you can't assign the contents to a variable. But you say
that you "sometimes have problems" which implies that sometimes it works.
Could you explain how it works?
And anyway why are your images in safe_mode_include_dir in the first place?
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
I love you, not only for what you are, but for what I am when I am with you.
-- Roy Croft
*/
--- End Message ---
--- Begin Message ---
Jason Wong wrote:
On Thursday 15 July 2004 19:52, Frank Holtschke wrote:
i have sometimes problems to include images. the reason are substrings
like <? in the image.
in that case the php-parser tries to parse the string and returns the
error:
parse error, unexpected ',' in
unforunatly there in no other way to include the image, cause the server
runs in safe_mode and
the image is located in the safe_mode_include_dir. therefore readfile
and things like that wont work.
Any suggestions how to protect an including file for getting parsed?
Even if you could prevent an included file from being parsed, I can't see how
it would help you as you can't assign the contents to a variable. But you say
that you "sometimes have problems" which implies that sometimes it works.
Could you explain how it works?
We just flush it on the display. the php-script is an image src like
<img src="showImage.php">
The showImage.php does an include of the image which is located out of
the DocumentRoot.
The image is generated by a cron script. Mostly it works but sometimes
we have the problem
described above.
And anyway why are your images in safe_mode_include_dir in the first place?
Cause php-scripts (owned by different uids => therefore the
safe_mode_include_dir ) of various virtual servers make use of the image.
--- End Message ---
--- Begin Message ---
I have a 3rd party SDK written in C. It includes a compiled .a file and
a header file (.h).
Is there any way that I can call the functions included in the SDK from
within a php script?
Regards,
Jeremy
--- End Message ---
--- Begin Message ---
Hi! I saw the php function flock(), since I never used it before so I
thought I would ask you folks a couple of questions.
1) Is this function good or is there a better function somewhere that I'm
not aware of?
2) If the flock() activated the file lock then is it possible that I
manually unlock the file? Like chmod or something through the Linux console
for example.
3) good example of script just in case..
Thanks,
FletchSOD
--- End Message ---
--- Begin Message ---
> Hi! I saw the php function flock(), since I never used it before so I
> thought I would ask you folks a couple of questions.
did you read all of the user comments on http://us2.php.net/flock
There is a bunch of good info in there
--- End Message ---
--- Begin Message ---
Yea, read that, very good info there. Alright, I'll make one from scratch
and do some testing to find what need to be add/change/remove to make it
more a rock solid script. Boy, it remind me of Perl.
Thanks,
FletchSOD
"Matt M." <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Hi! I saw the php function flock(), since I never used it before so I
> > thought I would ask you folks a couple of questions.
>
> did you read all of the user comments on http://us2.php.net/flock
>
> There is a bunch of good info in there
--- End Message ---
--- Begin Message ---
Nah! I'll settle for a simplier one... file_exists() by checking to see
if the file exist then spit out the error message. Meaning the file is in
use...
FletchSOD
"Matt M." <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Hi! I saw the php function flock(), since I never used it before so I
> > thought I would ask you folks a couple of questions.
>
> did you read all of the user comments on http://us2.php.net/flock
>
> There is a bunch of good info in there
--- End Message ---