|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Sun Feb 17 2008 - 21:43:23 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 18 Feb 2008 03:43:23 -0000 Issue 5299
Topics (messages 269430 through 269464):
Re: regex usage
269430 by: Shawn McKenzie
269431 by: Richard Heyes
269436 by: Nirmalya Lahiri
269439 by: Jim Lucas
Re: Protected ZIP file with password
269432 by: Petrus Bastos
269438 by: Daniel Brown
269445 by: Nick Stinemates
269446 by: Petrus Bastos
269447 by: Petrus Bastos
269460 by: Chris
269462 by: Petrus Bastos
269463 by: Nick Stinemates
Re: stream_select problem with signals
269433 by: Marcos Lois Bermúdez
Re: PHP/mySQL dropping zeros after inserting number into record
269434 by: Daniel Brown
269442 by: Nathan Rixham
Re: Session destruction problem
269435 by: Daniel Brown
269437 by: Adil Drissi
269441 by: tedd
269444 by: Adil Drissi
269454 by: Shawn McKenzie
269464 by: Adil Drissi
upload issue
269440 by: nihilism machine
269443 by: Børge Holen
269457 by: Chris
269458 by: Chris
269459 by: Børge Holen
Re: Better DB Class MySQL
269448 by: Larry Garfield
269461 by: Andrew Ballard
separating strings from extensions
269449 by: nihilism machine
269450 by: Daniel Brown
269451 by: John Meyer
269452 by: Børge Holen
269453 by: Brady Mitchell
269455 by: John Meyer
269456 by: Nick Stinemates
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Valedol wrote:
> Is there a mothod to check string`s length with regex or the only way is
> using strlen?
>
> I want string consisting of 4 digits
> and check string with this code:
>
> if (preg_match("/\d{4}/",$_POST[id]))
> { echo $_POST[id]; }
>
> but preg_match returns true when string consists of 4 or more digits
preg_match("/^\d{4}$/",$_POST['id'])
attached mail follows:
> Is there a mothod to check string`s length with regex or the only way is
> using strlen?
>
> I want string consisting of 4 digits
> and check string with this code:
>
> if (preg_match("/\d{4}/",$_POST[id]))
> { echo $_POST[id]; }
>
> but preg_match returns true when string consists of 4 or more digits
You could change the regex to use start/end anchors. Also, the trailing
comma in the length specifier bit means "4 or more" Eg:
if (preg_match("/^\d{4,}$/", $_POST['id'])){
echo $_POST['id'];
}
--
Richard Heyes
http://www.websupportsolutions.co.uk
Knowledge Base and Helpdesk software hosted for you - no
installation, no maintenance, new features automatic and free
** New Helpdesk demo now available **
attached mail follows:
--- Valedol <Valedol
goon.ru> wrote:
> Is there a mothod to check string`s length with regex or the only
> way is
> using strlen?
>
> I want string consisting of 4 digits
> and check string with this code:
>
> if (preg_match("/\d{4}/",$_POST[id]))
> { echo $_POST[id]; }
>
> but preg_match returns true when string consists of 4 or more
> digits
> --
To check only 4 digit, you have to specify max lengh of the string in
length specifier..
if (preg_match("/\d{4,4}/",$_POST[id]))
{ echo $_POST[id]; }
---
Nirmalya Lahiri
[+91-9433113536]
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
attached mail follows:
Valedol wrote:
> Is there a mothod to check string`s length with regex or the only way is
> using strlen?
>
> I want string consisting of 4 digits
> and check string with this code:
>
> if (preg_match("/\d{4}/",$_POST[id]))
> { echo $_POST[id]; }
>
> but preg_match returns true when string consists of 4 or more digits
Yes you can, but why do it this way? What advantage is it over the
following?
Given that this isn't a real intense regex, I don't know how much you
will save, but you could also do this.
if ( strlen(intval($_POST['id'])) == 4 ) {
echo $_POST['id'];
}
Not sure about speed, but it might be a little faster if you are looking
for performance.
Jim Lucas
attached mail follows:
Hi Nick,
Sorry, but I forgot to tell you that I can't use this exec neither
system commands because they are disabled for security precautions. So, Do
you have any other ideas on how can I do that?
Thanks for your help,
Petrus Bastos.
On Feb 17, 2008 5:15 AM, Nick Stinemates <nick
stinemates.org> wrote:
> Petrus Bastos wrote:
> > Hey folks,
> >
> > Do you know how can I create a protected zip file with password? Is
> > there anyway? I've search on the internet, but without success.
> >
> > Thank's in advance,
> > Petrus Bastos.
> >
> >
> The easiest way to accomplish this would be to write a wrapper function
> using the zip tool provided by (almost every) Linux distribution.
>
> <?php
>
> function zip($directory, $password, $saveAs) {
> return exec("zip -r $saveAs -P $password $directory";
> }
>
> print zip("/home/nick", "mypass", "/tmp/homebackup.zip");
>
> ?>
>
> Please note: the -P flag can be monitored on the local system so it is
> considered insecure.
> If you're going to be accepting input, you should also wrap your
> variables in escapeshellarg()
>
> http://us3.php.net/zip
> http://us.php.net/manual/en/function.exec.php
>
> from the zip manual entry
>
> THIS IS INSECURE! Many multi-user operating sys-tems
> provide ways for any user to see the current command line of any other
> user; even on stand-alone
> systems there is always the threat of over-the-shoulder peeking.
> Storing the plaintext password as
> part of a command line in an automated script is even worse. Whenever
> possible, use the non-echoing,
> interactive prompt to enter passwords. (And where security is truly
> important, use strong encryption
> such as Pretty Good Privacy instead of the relatively weak encryption
> provided by standard zipfile
> utilities.)
>
> ==================
> Nick Stinemates (nick
stinemates.org)
> http://nick.stinemates.org
>
> AIM: Nick Stinemates
> MSN: nickstinemates
hotmail.com
> Yahoo: nickstinemates
yahoo.com
> ==================
>
attached mail follows:
On Feb 16, 2008 3:39 PM, Petrus Bastos <petrusbastos
gmail.com> wrote:
> Hey folks,
>
> Do you know how can I create a protected zip file with password? Is
> there anyway? I've search on the internet, but without success.
If you have system() access, use something in the exec() family
(and be sure to properly sanitize that). Otherwise, there is probably
a PEAR or PECL module that will do the work for you.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Petrus Bastos wrote:
> Hi Nick,
>
> Sorry, but I forgot to tell you that I can't use this exec neither
> system commands because they are disabled for security precautions. So, Do
> you have any other ideas on how can I do that?
>
> Thanks for your help,
> Petrus Bastos.
>
> On Feb 17, 2008 5:15 AM, Nick Stinemates <nick
stinemates.org> wrote:
>
>
>> Petrus Bastos wrote:
>>
>>> Hey folks,
>>>
>>> Do you know how can I create a protected zip file with password? Is
>>> there anyway? I've search on the internet, but without success.
>>>
>>> Thank's in advance,
>>> Petrus Bastos.
>>>
>>>
>>>
>> The easiest way to accomplish this would be to write a wrapper function
>> using the zip tool provided by (almost every) Linux distribution.
>>
>> <?php
>>
>> function zip($directory, $password, $saveAs) {
>> return exec("zip -r $saveAs -P $password $directory";
>> }
>>
>> print zip("/home/nick", "mypass", "/tmp/homebackup.zip");
>>
>> ?>
>>
>> Please note: the -P flag can be monitored on the local system so it is
>> considered insecure.
>> If you're going to be accepting input, you should also wrap your
>> variables in escapeshellarg()
>>
>> http://us3.php.net/zip
>> http://us.php.net/manual/en/function.exec.php
>>
>> from the zip manual entry
>>
>> THIS IS INSECURE! Many multi-user operating sys-tems
>> provide ways for any user to see the current command line of any other
>> user; even on stand-alone
>> systems there is always the threat of over-the-shoulder peeking.
>> Storing the plaintext password as
>> part of a command line in an automated script is even worse. Whenever
>> possible, use the non-echoing,
>> interactive prompt to enter passwords. (And where security is truly
>> important, use strong encryption
>> such as Pretty Good Privacy instead of the relatively weak encryption
>> provided by standard zipfile
>> utilities.)
>>
>> ==================
>> Nick Stinemates (nick
stinemates.org)
>> http://nick.stinemates.org
>>
>> AIM: Nick Stinemates
>> MSN: nickstinemates
hotmail.com
>> Yahoo: nickstinemates
yahoo.com
>> ==================
>>
>>
>
>
Unfortunately I don't have any other ideas. Since PHP's implementation
of ZIP does not have password features you're left with the following
options:
* Write your own implementation based on RFC
* Write an interface to another app which can zip the file for you
* Something else I can't think of ;x
Sorry I don't have any other ideas.
attached mail follows:
Nick,
I thank you help! But unfortunalety I didn't find way to do this. I'll
continue trying. If you have any other idea, I'll appreciate to hear!
Best regards,
Petrus Bastos.
On Feb 17, 2008 4:57 PM, Nick Stinemates <nick
stinemates.org> wrote:
> Petrus Bastos wrote:
> > Hi Nick,
> >
> > Sorry, but I forgot to tell you that I can't use this exec neither
> > system commands because they are disabled for security precautions. So,
> Do
> > you have any other ideas on how can I do that?
> >
> > Thanks for your help,
> > Petrus Bastos.
> >
> > On Feb 17, 2008 5:15 AM, Nick Stinemates <nick
stinemates.org> wrote:
> >
> >
> >> Petrus Bastos wrote:
> >>
> >>> Hey folks,
> >>>
> >>> Do you know how can I create a protected zip file with password?
> Is
> >>> there anyway? I've search on the internet, but without success.
> >>>
> >>> Thank's in advance,
> >>> Petrus Bastos.
> >>>
> >>>
> >>>
> >> The easiest way to accomplish this would be to write a wrapper function
> >> using the zip tool provided by (almost every) Linux distribution.
> >>
> >> <?php
> >>
> >> function zip($directory, $password, $saveAs) {
> >> return exec("zip -r $saveAs -P $password $directory";
> >> }
> >>
> >> print zip("/home/nick", "mypass", "/tmp/homebackup.zip");
> >>
> >> ?>
> >>
> >> Please note: the -P flag can be monitored on the local system so it is
> >> considered insecure.
> >> If you're going to be accepting input, you should also wrap your
> >> variables in escapeshellarg()
> >>
> >> http://us3.php.net/zip
> >> http://us.php.net/manual/en/function.exec.php
> >>
> >> from the zip manual entry
> >>
> >> THIS IS INSECURE! Many multi-user operating sys-tems
> >> provide ways for any user to see the current command line of any other
> >> user; even on stand-alone
> >> systems there is always the threat of over-the-shoulder peeking.
> >> Storing the plaintext password as
> >> part of a command line in an automated script is even worse. Whenever
> >> possible, use the non-echoing,
> >> interactive prompt to enter passwords. (And where security is truly
> >> important, use strong encryption
> >> such as Pretty Good Privacy instead of the relatively weak
> encryption
> >> provided by standard zipfile
> >> utilities.)
> >>
> >> ==================
> >> Nick Stinemates (nick
stinemates.org)
> >> http://nick.stinemates.org
> >>
> >> AIM: Nick Stinemates
> >> MSN: nickstinemates
hotmail.com
> >> Yahoo: nickstinemates
yahoo.com
> >> ==================
> >>
> >>
> >
> >
> Unfortunately I don't have any other ideas. Since PHP's implementation
> of ZIP does not have password features you're left with the following
> options:
>
> * Write your own implementation based on RFC
> * Write an interface to another app which can zip the file for you
> * Something else I can't think of ;x
>
> Sorry I don't have any other ideas.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Unfortunately I don't have access to this family of methods because security
policy. Lefting this way out, I didn't find anyway on how to do that. If you
have any idea or know any module can do that, I'll appreciate to know too!
Thanks in advance,
Petrus Bastos.
On Feb 17, 2008 2:30 PM, Daniel Brown <parasane
gmail.com> wrote:
> On Feb 16, 2008 3:39 PM, Petrus Bastos <petrusbastos
gmail.com> wrote:
> > Hey folks,
> >
> > Do you know how can I create a protected zip file with password? Is
> > there anyway? I've search on the internet, but without success.
>
> If you have system() access, use something in the exec() family
> (and be sure to properly sanitize that). Otherwise, there is probably
> a PEAR or PECL module that will do the work for you.
>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
>
attached mail follows:
Petrus Bastos wrote:
> Unfortunately I don't have access to this family of methods because security
> policy. Lefting this way out, I didn't find anyway on how to do that. If you
> have any idea or know any module can do that, I'll appreciate to know too!
See if the pear package does what you want:
http://pear.php.net/package/File_Archive
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Chris,
Thanks for your help, but I think that package can't make what I want.
But , I appreciate your help anyway and if you have any other ideas, please
let me know! :)
Thanks,
Petrus Bastos.
On Feb 17, 2008 10:38 PM, Chris <dmagick
gmail.com> wrote:
> Petrus Bastos wrote:
> > Unfortunately I don't have access to this family of methods because
> security
> > policy. Lefting this way out, I didn't find anyway on how to do that. If
> you
> > have any idea or know any module can do that, I'll appreciate to know
> too!
>
> See if the pear package does what you want:
>
> http://pear.php.net/package/File_Archive
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
attached mail follows:
Petrus Bastos wrote:
> Chris,
>
> Thanks for your help, but I think that package can't make what I want.
> But , I appreciate your help anyway and if you have any other ideas, please
> let me know! :)
>
> Thanks,
> Petrus Bastos.
>
> On Feb 17, 2008 10:38 PM, Chris <dmagick
gmail.com> wrote:
>
>
>> Petrus Bastos wrote:
>>
>>> Unfortunately I don't have access to this family of methods because
>>>
>> security
>>
>>> policy. Lefting this way out, I didn't find anyway on how to do that. If
>>>
>> you
>>
>>> have any idea or know any module can do that, I'll appreciate to know
>>>
>> too!
>>
>> See if the pear package does what you want:
>>
>> http://pear.php.net/package/File_Archive
>>
>> --
>> Postgresql & php tutorials
>> http://www.designmagick.com/
>>
>>
>
>
I'm sure you know what you're doing, but maybe you'd be better off
letting us know the task / process to better understand what you'd like
to accomplish. From there, since it's obvious that PHP does not have
built in password functions, and that exec() is out of the question;
maybe we can figure out how to move onward.
--
==================
Nick Stinemates (nick
stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates
hotmail.com
Yahoo: nickstinemates
yahoo.com
==================
attached mail follows:
Nathan Rixham escribió:
>
> socket_strerror(socket_last_error()) maybe?
>
That i can see in PHP manual socket functions sre not bundled by default
in PHP 5.3.0 and above, so if i'm using the stream implementation, how i
can determine if a signal interrupt a stream_select call, the stream not
will to be a socket can be a any other stream supported types.
attached mail follows:
On Feb 16, 2008 6:22 PM, Rob Gould <gouldimg
mac.com> wrote:
> I've got a PHP script that inserts "00012345678" into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is "12345678".
>
> I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros?
>
> (or some way for PHP to tell mySQL not to chop off the zeros?)
Rob,
A few years ago, I developed a full-on inventory management system
(with barcode printing and assignment, as well as scanning) and found
that with Code 39 I didn't have the issue, but when using UPC or some
other format, I often had to convert the code to string(). Then
insert the data into a CHAR or VARCHAR column, because to most
systems, INT 001234 is equal to INT 1234, but with more overhead,
which is then normally trimmed.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Daniel Brown wrote:
> On Feb 16, 2008 6:22 PM, Rob Gould <gouldimg
mac.com> wrote:
>> I've got a PHP script that inserts "00012345678" into a record in a mySQL database (it's a barcode). Things work ok unless the number has preceding zeros, and then the zeros get cut off and all I get is "12345678".
>>
>> I have the mySQL database fieldtype set to bigint(14). If the maximum length a barcode can be is 14, is there a better fieldtype to use that will keep the zeros?
>>
>> (or some way for PHP to tell mySQL not to chop off the zeros?)
>
> Rob,
>
> A few years ago, I developed a full-on inventory management system
> (with barcode printing and assignment, as well as scanning) and found
> that with Code 39 I didn't have the issue, but when using UPC or some
> other format, I often had to convert the code to string(). Then
> insert the data into a CHAR or VARCHAR column, because to most
> systems, INT 001234 is equal to INT 1234, but with more overhead,
> which is then normally trimmed.
>
zerofill is the way - the stupid but works way is to store the barcodes
backwards :D or indeed base convert them from 10 to 32..
attached mail follows:
On Feb 16, 2008 3:31 PM, Adil Drissi <adil.drissi
yahoo.com> wrote:
> Hi everybody,
>
> I need help with sessions.
> I have a simple authentification relying only on
> sessions (i don't use cookies).
Just to let you know, if you're using sessions, you're using
cookies. You're not setting the data in the client-side cookie, but a
cookie is still installed on the system containing the PHPSESSID.
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Hi,
I suppose this can be used to solve the problem i
posted. Can you please tell me how, or send a link to
ressource explaining that?
Thanks
--- Daniel Brown <parasane
gmail.com> wrote:
> On Feb 16, 2008 3:31 PM, Adil Drissi
> <adil.drissi
yahoo.com> wrote:
> > Hi everybody,
> >
> > I need help with sessions.
> > I have a simple authentification relying only on
> > sessions (i don't use cookies).
>
> Just to let you know, if you're using sessions,
> you're using
> cookies. You're not setting the data in the
> client-side cookie, but a
> cookie is still installed on the system containing
> the PHPSESSID.
>
> --
> </Dan>
>
> Daniel P. Brown
> Senior Unix Geek
> <? while(1) { $me = $mind--; sleep(86400); } ?>
>
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
attached mail follows:
At 12:31 PM -0800 2/16/08, Adil Drissi wrote:
>Hi everybody,
>
>I need help with sessions.
>I have a simple authentification relying only on
>sessions (i don't use cookies). After the user submits
>his username and password, the script checks if that
>corresponds to a record in a mysql table. If this is
>the case "$_SESSION['sessioname'] = $_POST['login'];".
>the $_SESSION['sessioname'] is checked in subsequent
>pages to see if the user is connected or not.
>The problem is after the user logs out, and after that
>uses the previous button of the browser he becomes
>connected. How can i prevent this please.
>
>Here is my logout.php:
>
><?php
>session_start();
>unset($_SESSION["sessioname"]);
>session_destroy();
>header("location: index.php");
>?>
That will destroy the session, but not the browser history.
You'll need javascript to alter window history.
Google "window.history.forward"
Here's one link that may help:
http://www.4guysfromrolla.com/webtech/111500-1.2.shtml
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
Hi,
Thanks for the link, it is very interesting, but as
the author says, the solutions are not perfect.
I'm wondering how yahoo mail for example are doing, or
maybe they are using something else (not php)?
Thank you
--- tedd <tedd.sperling
gmail.com> wrote:
> At 12:31 PM -0800 2/16/08, Adil Drissi wrote:
> >Hi everybody,
> >
> >I need help with sessions.
> >I have a simple authentification relying only on
> >sessions (i don't use cookies). After the user
> submits
> >his username and password, the script checks if
> that
> >corresponds to a record in a mysql table. If this
> is
> >the case "$_SESSION['sessioname'] =
> $_POST['login'];".
> >the $_SESSION['sessioname'] is checked in
> subsequent
> >pages to see if the user is connected or not.
> >The problem is after the user logs out, and after
> that
> >uses the previous button of the browser he becomes
> >connected. How can i prevent this please.
> >
> >Here is my logout.php:
> >
> ><?php
> >session_start();
> >unset($_SESSION["sessioname"]);
> >session_destroy();
> >header("location: index.php");
> >?>
>
> That will destroy the session, but not the browser
> history.
>
> You'll need javascript to alter window history.
>
> Google "window.history.forward"
>
> Here's one link that may help:
>
>
http://www.4guysfromrolla.com/webtech/111500-1.2.shtml
>
> Cheers,
>
> 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
>
>
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
attached mail follows:
Adil Drissi wrote:
> Hi everybody,
>
> I need help with sessions.
> I have a simple authentification relying only on
> sessions (i don't use cookies). After the user submits
> his username and password, the script checks if that
> corresponds to a record in a mysql table. If this is
> the case "$_SESSION['sessioname'] = $_POST['login'];".
> the $_SESSION['sessioname'] is checked in subsequent
> pages to see if the user is connected or not.
> The problem is after the user logs out, and after that
> uses the previous button of the browser he becomes
> connected. How can i prevent this please.
>
> Here is my logout.php:
>
> <?php
> session_start();
> unset($_SESSION["sessioname"]);
> session_destroy();
> header("location: index.php");
> ?>
>
> Thank you for advance
>
>
> ____________________________________________________________________________________
> Looking for last minute shopping deals?
> Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
I don't think they are "reconnected". What happens if they logout, then
hit back, then hit refresh? Are they loggedin? Probably not. It may
just appear that way because the back bottom brings up a cache of the
previous page. But once the user tries to do anything that requires
that they be loggedin, I doubt they can.
-Shawn
attached mail follows:
Well, i'm doing all that. Maybe something is wrong in
my code. I'll arrange my code in a way that it will be
easy to run and i'll post it. I think like that,
you'll see by yourself and you gonna help to fix that
for sure.
Thank you
--- Shawn McKenzie <nospam
mckenzies.net> wrote:
> Adil Drissi wrote:
> > Hi everybody,
> >
> > I need help with sessions.
> > I have a simple authentification relying only on
> > sessions (i don't use cookies). After the user
> submits
> > his username and password, the script checks if
> that
> > corresponds to a record in a mysql table. If this
> is
> > the case "$_SESSION['sessioname'] =
> $_POST['login'];".
> > the $_SESSION['sessioname'] is checked in
> subsequent
> > pages to see if the user is connected or not.
> > The problem is after the user logs out, and after
> that
> > uses the previous button of the browser he becomes
> > connected. How can i prevent this please.
> >
> > Here is my logout.php:
> >
> > <?php
> > session_start();
> > unset($_SESSION["sessioname"]);
> > session_destroy();
> > header("location: index.php");
> > ?>
> >
> > Thank you for advance
> >
> >
> >
>
____________________________________________________________________________________
> > Looking for last minute shopping deals?
> > Find them fast with Yahoo! Search.
>
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>
> I don't think they are "reconnected". What happens
> if they logout, then
> hit back, then hit refresh? Are they loggedin?
> Probably not. It may
> just appear that way because the back bottom brings
> up a cache of the
> previous page. But once the user tries to do
> anything that requires
> that they be loggedin, I doubt they can.
>
> -Shawn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
attached mail follows:
any idea why this fails?this is the error: "Sorry, there was a problem
uploading your file"
<?php
require_once("classes/db.class.php");
$target = "";
$fileName = basename( $_FILES['uploaded']['name']);
$extension = strtolower(strrchr($fileName,"."));
$DB = new DB();
$insertID = $DB->insert_sql("INSERT INTO CMS_Media (File_Name) VALUES
('')");
$target = "media/" . $insertID . $extension;
//echo $target;
if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
// Error
echo "File was uploaded!";
} else {
echo "Sorry, there was a problem uploading your file.";
}
chmod($target, 0755);
header("Location: crop.php?imageName=$newFileName");
?>
-------------------------------
Edward H. Hotchkiss
Chief Technical Officer
Durgle, INC
edward
durgle.com
http://www.durgle.com
-------------------------------
attached mail follows:
On Sunday 17 February 2008 19:22:03 nihilism machine wrote:
> any idea why this fails?this is the error: "Sorry, there was a problem
> uploading your file"
>
> <?php
>
> require_once("classes/db.class.php");
>
> $target = "";
> $fileName = basename( $_FILES['uploaded']['name']);
> $extension = strtolower(strrchr($fileName,"."));
> $DB = new DB();
> $insertID = $DB->insert_sql("INSERT INTO CMS_Media (File_Name) VALUES
> ('')");
> $target = "media/" . $insertID . $extension;
> //echo $target;
> if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
> // Error
> echo "File was uploaded!";
> } else {
> echo "Sorry, there was a problem uploading your file.";
> }
>
> chmod($target, 0755);
>
> header("Location: crop.php?imageName=$newFileName");
>
> ?>
>
This looks weird. is this actually anything: $_FILES['uploaded']['tmp_name'].
I always used $_FILES['tmp_name'], $_FILES['name'] and such
>
>
>
> -------------------------------
> Edward H. Hotchkiss
> Chief Technical Officer
> Durgle, INC
> edward
durgle.com
> http://www.durgle.com
> -------------------------------
--
---
Børge Holen
http://www.arivene.net
attached mail follows:
nihilism machine wrote:
> any idea why this fails?this is the error: "Sorry, there was a problem
> uploading your file"
It can't move the file to the $target location, or maybe the file wasn't
uploaded properly in the first place.
What's in $_FILES['uploaded']['error'] ?
http://www.php.net/manual/en/features.file-upload.errors.php
> if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
> // Error
> echo "File was uploaded!";
> } else {
> echo "Sorry, there was a problem uploading your file.";
> }
>
> chmod($target, 0755);
Files do not need to be 0755, they should be 0644 unless you want them
to actually run something (eg they are a shell script or perl script
that you'd run from the cmd line).
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Børge Holen wrote:
> On Sunday 17 February 2008 19:22:03 nihilism machine wrote:
>> any idea why this fails?this is the error: "Sorry, there was a problem
>> uploading your file"
>>
>> <?php
>>
>> require_once("classes/db.class.php");
>>
>> $target = "";
>> $fileName = basename( $_FILES['uploaded']['name']);
>> $extension = strtolower(strrchr($fileName,"."));
>> $DB = new DB();
>> $insertID = $DB->insert_sql("INSERT INTO CMS_Media (File_Name) VALUES
>> ('')");
>> $target = "media/" . $insertID . $extension;
>> //echo $target;
>> if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
>> // Error
>> echo "File was uploaded!";
>> } else {
>> echo "Sorry, there was a problem uploading your file.";
>> }
>>
>> chmod($target, 0755);
>>
>> header("Location: crop.php?imageName=$newFileName");
>>
>> ?>
>>
>
> This looks weird. is this actually anything: $_FILES['uploaded']['tmp_name'].
> I always used $_FILES['tmp_name'], $_FILES['name'] and such
According to php docs it's always a multi-dimensional array:
http://www.php.net/manual/en/features.file-upload.php
The 'uploaded' is what you call the file input in your form.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
On Monday 18 February 2008 00:59:31 Chris wrote:
> Børge Holen wrote:
> > On Sunday 17 February 2008 19:22:03 nihilism machine wrote:
> >> any idea why this fails?this is the error: "Sorry, there was a problem
> >> uploading your file"
> >>
> >> <?php
> >>
> >> require_once("classes/db.class.php");
> >>
> >> $target = "";
> >> $fileName = basename( $_FILES['uploaded']['name']);
> >> $extension = strtolower(strrchr($fileName,"."));
> >> $DB = new DB();
> >> $insertID = $DB->insert_sql("INSERT INTO CMS_Media (File_Name) VALUES
> >> ('')");
> >> $target = "media/" . $insertID . $extension;
> >> //echo $target;
> >> if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
> >> // Error
> >> echo "File was uploaded!";
> >> } else {
> >> echo "Sorry, there was a problem uploading your file.";
> >> }
> >>
> >> chmod($target, 0755);
> >>
> >> header("Location: crop.php?imageName=$newFileName");
> >>
> >> ?>
> >
> > This looks weird. is this actually anything:
> > $_FILES['uploaded']['tmp_name']. I always used $_FILES['tmp_name'],
> > $_FILES['name'] and such
>
> According to php docs it's always a multi-dimensional array:
> http://www.php.net/manual/en/features.file-upload.php
>
> The 'uploaded' is what you call the file input in your form.
oh well, as long as it works for me, thanks for the info
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
--
---
Børge Holen
http://www.arivene.net
attached mail follows:
On Thursday 14 February 2008, Richard Lynch wrote:
> On Sun, February 10, 2008 9:31 am, Jochem Maas wrote:
> > Larry Garfield schreef:
> >> http://www.php.net/pdo
> >>
> >> All the cool kids are doing it.
> >
> > not true - some of them use firebird ;-)
>
> And some have figured out that PDO does not quite live up to its
> promise (yet) and needs some more work...
>
> Particularly for the commercial DBs, as I understand it...
You say that like I care about non-open-source databases. It's not PDO's
fault that Oracle still thinks it's 1988. :-)
Even if you're just using MySQL, PDO is far nicer than ext/mysql and
ext/mysqli is not widely installed enough to be useful for those of us who
have to deal with shared hosts.
--
Larry Garfield AIM: LOLG42
larry
garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
attached mail follows:
On Feb 17, 2008 3:49 PM, Larry Garfield <larry
garfieldtech.com> wrote:
> On Thursday 14 February 2008, Richard Lynch wrote:
> > On Sun, February 10, 2008 9:31 am, Jochem Maas wrote:
> > > Larry Garfield schreef:
> > >> http://www.php.net/pdo
> > >>
> > >> All the cool kids are doing it.
> > >
> > > not true - some of them use firebird ;-)
> >
> > And some have figured out that PDO does not quite live up to its
> > promise (yet) and needs some more work...
> >
> > Particularly for the commercial DBs, as I understand it...
>
> You say that like I care about non-open-source databases. It's not PDO's
> fault that Oracle still thinks it's 1988. :-)
>
> Even if you're just using MySQL, PDO is far nicer than ext/mysql and
> ext/mysqli is not widely installed enough to be useful for those of us who
> have to deal with shared hosts.
>
>
You say that like you're the only person using PHP for databases. ;-)
Perhaps you don't care; some of us do. (SQL Server in my case, not Oracle.)
I like the idea of PDO, but I don't like the way a couple things work with
regard to parameterized queries and some things just flat out don't work
right.
Andrew
attached mail follows:
i am using this code to get the extension of a filename:
$extension = strtolower(strrchr($fileName,"."));
how can i get the text BEFORE the . (period)
?
thanks in advance.
-e
attached mail follows:
On Feb 17, 2008 5:37 PM, nihilism machine <nihilismmachine
gmail.com> wrote:
> i am using this code to get the extension of a filename:
>
> $extension = strtolower(strrchr($fileName,"."));
>
> how can i get the text BEFORE the . (period)
You can STFW and RTFM. This list should never be your first place
to ask simple questions.
In any case....
<?
$split = explode('.',strtolower($fileName));
$name = $split[0];
$ext = $split[1];
?>
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>
attached mail follows:
Daniel Brown wrote:
> On Feb 17, 2008 5:37 PM, nihilism machine <nihilismmachine
gmail.com> wrote:
>
>> i am using this code to get the extension of a filename:
>>
>> $extension = strtolower(strrchr($fileName,"."));
>>
>> how can i get the text BEFORE the . (period)
>>
>
> You can STFW and RTFM. This list should never be your first place
> to ask simple questions.
>
> In any case....
>
> <?
> $split = explode('.',strtolower($fileName));
> $name = $split[0];
> $ext = $split[1];
> ?>
>
>
Flame job aside, that's going to fail on a compound extension such as
".tar.gz" by just returning .tar
attached mail follows:
On Monday 18 February 2008 00:10:30 John Meyer wrote:
> Daniel Brown wrote:
> > On Feb 17, 2008 5:37 PM, nihilism machine <nihilismmachine
gmail.com>
wrote:
> >> i am using this code to get the extension of a filename:
> >>
> >> $extension = strtolower(strrchr($fileName,"."));
> >>
> >> how can i get the text BEFORE the . (period)
> >
> > You can STFW and RTFM. This list should never be your first place
> > to ask simple questions.
> >
> > In any case....
> >
> > <?
> > $split = explode('.',strtolower($fileName));
> > $name = $split[0];
> > $ext = $split[1];
> > ?>
>
> Flame job aside, that's going to fail on a compound extension such as
> ".tar.gz" by just returning .tar
so.
it.will.fail.this.one.to.txt
and a fix would also fail because you would have to hardcord everygoddamn
ending if thats what youre after. How many do you care to count for?
I would say stick with the last dot, if its not particulary often you stumble
over those .tar.bz2 endings.
what does he want to upload anyway?
Oi you, whats yer task?
--
---
Børge Holen
http://www.arivene.net
attached mail follows:
On Feb 17, 2008, at 256PM, Daniel Brown wrote:
> On Feb 17, 2008 5:37 PM, nihilism machine
> <nihilismmachine
gmail.com> wrote:
>> i am using this code to get the extension of a filename:
>>
>> $extension = strtolower(strrchr($fileName,"."));
>>
>> how can i get the text BEFORE the . (period)
>
> You can STFW and RTFM. This list should never be your first place
> to ask simple questions.
PLEASE start using the PHP manual!
http://php.net/pathinfo
http://php.net/basename
Brady
attached mail follows:
Børge Holen wrote:
> On Monday 18 February 2008 00:10:30 John Meyer wrote:
>
>> Daniel Brown wrote:
>>
>>> On Feb 17, 2008 5:37 PM, nihilism machine <nihilismmachine
gmail.com>
>>>
> wrote:
>
>>>> i am using this code to get the extension of a filename:
>>>>
>>>> $extension = strtolower(strrchr($fileName,"."));
>>>>
>>>> how can i get the text BEFORE the . (period)
>>>>
>>> You can STFW and RTFM. This list should never be your first place
>>> to ask simple questions.
>>>
>>> In any case....
>>>
>>> <?
>>> $split = explode('.',strtolower($fileName));
>>> $name = $split[0];
>>> $ext = $split[1];
>>> ?>
>>>
>> Flame job aside, that's going to fail on a compound extension such as
>> ".tar.gz" by just returning .tar
>>
>
> so.
>
> it.will.fail.this.one.to.txt
>
> and a fix would also fail because you would have to hardcord everygoddamn
> ending if thats what youre after. How many do you care to count for?
> I would say stick with the last dot, if its not particulary often you stumble
> over those .tar.bz2 endings.
>
You could also stick with the first, i.e.:
<?
$split = explode('.',strtolower($fileName),1);
$name = $split[0];
$ext = $split[1];
?>
attached mail follows:
John Meyer wrote:
> Børge Holen wrote:
>> On Monday 18 February 2008 00:10:30 John Meyer wrote:
>>
>>> Daniel Brown wrote:
>>>
>>>> On Feb 17, 2008 5:37 PM, nihilism machine
>>>> <nihilismmachine
gmail.com>
>> wrote:
>>
>>>>> i am using this code to get the extension of a filename:
>>>>>
>>>>> $extension = strtolower(strrchr($fileName,"."));
>>>>>
>>>>> how can i get the text BEFORE the . (period)
>>>>>
>>>> You can STFW and RTFM. This list should never be your first place
>>>> to ask simple questions.
>>>>
>>>> In any case....
>>>>
>>>> <?
>>>> $split = explode('.',strtolower($fileName));
>>>> $name = $split[0];
>>>> $ext = $split[1];
>>>> ?>
>>>>
>>> Flame job aside, that's going to fail on a compound extension such as
>>> ".tar.gz" by just returning .tar
>>>
>>
>> so.
>>
>> it.will.fail.this.one.to.txt
>> and a fix would also fail because you would have to hardcord
>> everygoddamn ending if thats what youre after. How many do you care
>> to count for?
>> I would say stick with the last dot, if its not particulary often you
>> stumble over those .tar.bz2 endings.
>>
>
>
> You could also stick with the first, i.e.:
>
> <?
> $split = explode('.',strtolower($fileName),1);
> $name = $split[0];
> $ext = $split[1];
> ?>
>
Or you can stop spreading bad advice and listen to Brady Mitchell
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]