OSEC

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 7 Mar 2008 23:56:14 -0000 Issue 5335

php-general-digest-helplists.php.net
Date: Fri Mar 07 2008 - 17:56:14 CST


php-general Digest 7 Mar 2008 23:56:14 -0000 Issue 5335

Topics (messages 271120 through 271149):

Re: Transferring files between computers using php
        271120 by: Aschwin Wesselius
        271122 by: Shawn McKenzie
        271123 by: Richard Lynch
        271124 by: Richard Lynch

Re: CVS Scripts
        271121 by: Eric Butera
        271129 by: tedd

Re: How to measure memory leakage/usage in PHP?
        271125 by: Richard Lynch

Re: Universaly Accepted Naming Conventions..?
        271126 by: Richard Lynch

Re: Pear Installation Problem - Ubuntu
        271127 by: Richard Lynch

Re: Preserving URL after redirect?
        271128 by: Richard Lynch
        271130 by: Richard Lynch

Re: imagerotate
        271131 by: Richard Lynch

Re: Array questions...
        271132 by: Richard Lynch

Re: Variable post as array
        271133 by: Richard Lynch

Re: Logging session timeout in DB
        271134 by: Richard Lynch

Re: validating mysql bound date
        271135 by: Richard Lynch
        271144 by: Larry Brown

Re: regular expressions question
        271136 by: Richard Lynch

Re: Hot job opportunity - Sr. Software Developer/Architect
        271137 by: Richard Lynch

SESSIOn when cookies are disabled
        271138 by: chetan rane
        271139 by: Daniel Brown
        271140 by: Bastien Koert
        271141 by: chetan rane

programming and design fees
        271142 by: Lamp Lists
        271143 by: Per Jessen

Newbie - Undefined Index Variable
        271145 by: revDAVE
        271146 by: Daniel Brown

Posting Summary for Week Ending 7 March, 2008: php-generallists.php.net
        271147 by: PostTrack [Dan Brown]

Generating JavaScript menus on-the-fly
        271148 by: Ken Kixmoeller

Deprecated configure options
        271149 by: Ian M. Evans

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Peter Ford wrote:
> Here's overkill: use "fuse" to make two sshfs filesystems :)
>
> # Make some directories to mount the remote stuff onto
> mkdir -p mount_point_for_B
> mkdir -p mount_point_for_C
>
> # Use 'fuse' to make SSHFS mounts from the remotes to the new directories
> sshfs B:/path_to_where_the_file_is mount_point_for_B
> sshfs C:/path_to_where_the_file_goes mount_point_for_C
>
> # Copy the file across: repeat this step every few seconds (cron job?)
> cp mount_point_for_B/the_file_to_copy mount_point_for_C
>
> # Unmount the SSHFS mounts when you're finished
> fusermount -u mount_point_for_B
> fusermount -u mount_point_for_C
>

That's overkill indeed and can make for some cool flaws on you
filesystem too. When an unmount won't succeed the next execution via
cron will fail since the mount point already exists etc.

Every few seconds an update over to 2 systems is somehow weird. I think
it is very intensive and like I said if somehow one part of the syncing
'hangs', it can fill memory or bandwidth very quickly.

So, I can't still figure out what has to be done over to these computers
every minute or whatever. The situation is not really clear to me.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

attached mail follows:


Peter Ford wrote:
> Aschwin Wesselius wrote:
>> Rahul wrote:
>>> I have a small file to be transferred between two computers every few
>>> seconds. I'm using unix with a bare bones version of php, i.e. just
>>> the original thing that gets installed when I run "yum install php".
>>> As there is no webserver on any of these machines, I was wondering if
>>> there is a way to transfer a small file between them and if there is,
>>> could someone be kind enough to provide me with an example please?
>>>
>>> Thank You
>> You can use netcat (nc), but that doesn't run in daemon mode. You can
>> use them both ways (client / server, sending / receiving). You can use
>> them on the commandline with a cronjob or whatever.
>>
>> Netcat makes it possible to do this, to send content over to port 2200
>> of 192.168.1.1:
>>
>> cat textfile.txt | nc 192.168.1.1 2200
>>
>> On 192.168.1.1 all you do is something like this:
>>
>> nc -l -p 2200 > textfile.txt
>>
>> I don't know all the options in depth and may not work like scp does
>> (which is way more secure).
>>
>> So I would go with scp in a cronjob, but netcat is still an option.
>>
>>
>
> Here's overkill: use "fuse" to make two sshfs filesystems :)
>
> # Make some directories to mount the remote stuff onto
> mkdir -p mount_point_for_B
> mkdir -p mount_point_for_C
>
> # Use 'fuse' to make SSHFS mounts from the remotes to the new directories
> sshfs B:/path_to_where_the_file_is mount_point_for_B
> sshfs C:/path_to_where_the_file_goes mount_point_for_C
>
> # Copy the file across: repeat this step every few seconds (cron job?)
> cp mount_point_for_B/the_file_to_copy mount_point_for_C
>
> # Unmount the SSHFS mounts when you're finished
> fusermount -u mount_point_for_B
> fusermount -u mount_point_for_C
>
>
> Still not PHP though...
>
>
>
Easier in a cron:

scp userB:/path/file /tmp/
scp /tmp/file userC:/path/

attached mail follows:


On Thu, March 6, 2008 7:58 pm, Rahul wrote:
> I have a small file to be transferred between two computers every few
> seconds.

Use rsync

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Thu, March 6, 2008 11:10 pm, Chris wrote:
>
>> If ssh keys are installed on the remote hosts then scp works
>> transparently and you just stick the scp in a cron job. Am I
>> missing
>> something?
>
> Yeh - looks like you have to log in to "A" and then it uses
> key-forwarding to let you log in to "B" and "C":
>
> ---
> To login to B and C I should use A because it has a SSH key. I don't
> have any other way of accessing these two computers.
> ---
>
> ie B & C can't talk to each other directly (that's my understanding
> anyway).

Scenario #1:
B&C can't talk for a reason.
Ergo, you SHOULD use A as a go-between

Scenario #2:
B&C could talk if you wanted them to.
Install SSH key-pairs on B&C and then use rsync over SSH

There's still no PHP involved, really...

Maybe there should be, in that the two programs should, perhaps,
expose something as web services via RCP, REST, or SOAP, but not from
what has been explained so far...

OP:
Please give us the "big picture" of what B&C are doing, and what info
needs to go back and forth.

This could change the answers dramatically.

Or not. :-)

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, Mar 7, 2008 at 3:58 AM, Adrian Walls <awallskpoint.co.uk> wrote:
> I am going to code this up myself with wrappers around the cvs commands I need.

Good luck! Sounds like that might be the best solution since you have
such specific needs.

The whole signature thing was just some friendly prodding because I
see them all over the place. I just happened to be between things at
work enough to waste some time on it. I even threw in the ;) to
hopefully get that across. :) I'd better stop typing now before tedd
counts my bytes. :(

attached mail follows:


At 8:05 AM -0500 3/7/08, Eric Butera wrote:
>On Fri, Mar 7, 2008 at 3:58 AM, Adrian Walls <awallskpoint.co.uk> wrote:
>> I am going to code this up myself with wrappers around the cvs
>>commands I need.
>
>Good luck! Sounds like that might be the best solution since you have
>such specific needs.
>
>The whole signature thing was just some friendly prodding because I
>see them all over the place. I just happened to be between things at
>work enough to waste some time on it. I even threw in the ;) to
>hopefully get that across. :) I'd better stop typing now before tedd
>counts my bytes. :(

Hey, don't jump bad on my ass, I was just commenting about the point
you raised. :-)

I think this got out of hand anyway -- public apologies to anyone who
took offense.

Cheers,

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

attached mail follows:


On Wed, March 5, 2008 9:57 pm, Zareef Ahmed wrote:
> I am looking into the concepts behind memory management in PHP.
> Which
> kind of approach will be best to measure memory leakage or usage in a
> PHP
> script?
>
> I can measure my apache process but is there any way by which I can
> know
> which exact part of script is consuming how much memory?

valgrind is an excellent tool for this sort of thing.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Wed, March 5, 2008 1:06 pm, John Papas wrote
> Are there any in PHP?
>
> It seems like there are those that draw upon the C/unix naming
> conventions and those that follow the Java/OO style.

There are several popular "standards" out there.

The PEAR coding standard and the Zend one tend to get mentioned a lot.

The most important thing is to be consistent yourself, rather than to
follow a specific standard.

Anybody halfway decent can follow what you did if you are consistent.

> Even PHP's native syntax (like function names pre/post v5) are not
> consistent.

They ARE consistent with the underlying libraries, which is more
important, really, because that means you don't have to waste hours
figuring out what PHP did to shoe-horn the other library's functions
into some other system.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


SPM decided to move stuff to a different place, namely inside of a
/usr/share/php/PEAR directory, instead of just /usr/share/PEAR.

So change your include path and be done with it.

On Wed, March 5, 2008 11:59 am, Stephen wrote:
> My LAMP is on Ubuntu 7.10
>
> I am trying to use PEAR, for the first time, and get an error about
> the
> include file not being found.
>
> It is not there.
>
> phpinfo() has include_path set to .:/usr/share/php:/usr/share/pear
>
> Here is my error:
>
> Warning: require_once(HTML/QuickForm.php) [function.require-once]:
> failed to open stream: No such file or directory in
> /home/stephen/www/roissy.ca/public_html/quotesForm.php on line 3
>
> Fatal error: require_once() [function.require]: Failed opening
> required
> 'HTML/QuickForm.php' (include_path='.:/usr/share/php:/usr/share/pear')
> in /home/stephen/www/roissy.ca/public_html/quotesForm.php on line 3
>
> Now I have always just used the Synaptic Package Manager, and I just
> did
> a reinstall of PEAR.
>
> But there is no /usr/share/pear directory.
>
> I have a /usr/share/php/PEAR and it has things that look like
> installation files.
>
> I am venturing where I have not before. I have never performed any
> kind
> of CLI install.
>
> Can anyone help me figure out how to get the installation fixed?
>
> Thanks
> Stephen
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Wed, March 5, 2008 11:18 am, Skip Evans wrote:

> "shortname", in this case "madison", and then sets
> a session variables for school ID that allows the
> user to access this school's data.
>
> Then it redirects back to
>
> http://prepcube.com/

Don't redirect to this.

Your session data has "wi/madison" in it, redirect to that:

header("Location:
http://precube.com/$_SESSION[state]/$_SESSION[shortname]");

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Thu, March 6, 2008 6:42 am, Jochem Maas wrote:
> big boys use mod_rewrite, go grab a kilt :-)

If mod_rewrite gives you the willies...

You don't really NEED it here...

Just don't create /wi/* directories, and use $_SERVER['PATH_INFO']
instead.

Store all the school data somewhere else, and let the PHP/AJAX spew it
out as needed based on the URL, with only an index.php file running
the whole site.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Wed, March 5, 2008 11:17 am, Zeshan Uddin wrote:

> *************************
> Code for rotate.php
>
> <?php
> // File and rotation
> $filename = 'image.png';
> $degrees = 18;
>
> // Content type
> header('Content-type: image/png');
>
> // Load
> $source = imagecreatefrompng($filename);
>
> // Rotate
> $rotate = imagerotate($source, $degrees, 0);

This line does the actual rotation, and, along with $degrees = 18, is
all you need to add to the other script.

>
> // Output
> imagepng($rotate);
> ?>
>
> ============================
>
> Code for resize.php
>
> <?php
> $src_img = imagecreatefrompng('image.png');
> $srcsize = getimagesize('image.png');
>
> $dest_x = 200;
> $dest_y = (200 / $srcsize[0]) * $srcsize[1];
> $dst_img = imagecreatetruecolor($dest_x, $dest_y);
>
> imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0,
> $dest_x, $dest_y, $srcsize[0], $srcsize[1]);

You can add them here, after the image is resized, and you are done.

> header("content-type: image/png");
>
> imagepng($dst_img);
> imagedestroy($src_img);
> imagedestroy($dst_img);
> ?>
>
>
> thanks
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Wed, March 5, 2008 9:35 am, Robert Cummings wrote:

No textbook, but here's some advice...

Think of a variable like a house address for an actual house.

123 Maple Street

An array is just an apartment building:

125 Maple Street, Unit 1
125 Maple Street, Unit 2
125 Maple Street, Unit 3
.
.
.

When you want to talk about the whole array (building) you can use
just the street address.

If you want a specific unit, you have to add the [$unit] part.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Are you really using temp_name when you want tmp_name?

On Wed, March 5, 2008 4:37 am, Pieter du Toit wrote:
> Just to add, if i try to echo the $_FILES['txtPhoto']['temp_name'] it
> tells
> me that temp_name is also an array, but when i echo
> $_FILES['txtPhoto']['name'] it gives me the correct name. Also with a
> vardump i can see that temp name is ["tmp_name"]=> string(14)
> "/tmp/phplR1WSl" and not an array by itself.
>
> Im going crazy here
>
> ""Pieter du Toit"" <pieterlpwebdesign.co.za> wrote in message
> news:E7.13.27925.EDE6EC74pb1.pair.com...
>> Hi
>>
>> I have this weird problem, when i select a file to upload, the
>> variable
>> arrives as an array at the action php file, this is the code, and
>> the
>> variable name is txtPhoto
>>
>> <? include ("userpass.inc"); ?>
>>
>> <html>
>>
>> <link rel="STYLESHEET" type="TEXT/CSS" href="specials.css">
>>
>> <title>Specials Update</title>
>>
>> </head>
>>
>> <? include ("body_begin.inc"); ?>
>>
>> <?
>>
>> echo "<form ENCTYPE=\"multipart/form-data\" method=\"POST\"
>> name=\"Edit
>> Special\" action=\"specials_proc.php\">\n";
>>
>> echo "<input type=\"hidden\" name=\"keyClient_Id\"
>> value=\"$g_client_id\">";
>>
>> echo "<input type=\"hidden\" name=\"keySpecial\"
>> value=\"$special\">";
>>
>> echo "<input type=\"hidden\" name=\"k_subsystem_id\"
>> value=\"$k_subsystem_id\">";
>>
>> echo "<table align=\"center\" class=\"EditView\" border=\"0\"
>> cellspacing=\"0\" cellpadding=\"0\" width=\"80%\">\n";
>>
>>
>>
>> if ($special != "")
>>
>> {
>>
>> $new = 0;
>>
>> echo "<tr class=\"MainHeader\"><th colspan=\"2\">Edit
>> Special</th></tr>\n";
>>
>> $result = mysql("zululandcoza", "select * from client_specials where
>> client_id = $g_client_id and special = $special");
>>
>> if (list($client_id, $special, $description, $special_type, $price,
>> $discount, $startdate, $enddate) = mysql_fetch_row($result))
>>
>> {
>>
>> }
>>
>> }
>>
>> else
>>
>> {
>>
>> $new = 1;
>>
>> echo "<tr class=\"Header\"><th colspan=\"2\"><h1>New Special (this
>> page is
>> undergoing maintenance, please try again later)</h1></th></tr>\n";
>>
>> $result = mysql("zululandcoza", "select max(special) from
>> client_specials
>> where client_id = $client_id");
>>
>> if (list($max_special) = mysql_fetch_row($result))
>>
>> {
>>
>> $special = $max_special + 1;
>>
>> }
>>
>> }
>>
>>
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\"
>> class=\"Prompt\">Special&nbsp;Number</td>\n";
>>
>> if ($new)
>>
>> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
>> name=\"txtSpecial\" maxlength=\"5\" size=\"5\"
>> value=\"$special\"></input></td>\n";
>>
>> else
>>
>> echo " <td align=\"left\" class=\"Number\"><input type=\"text\"
>> name=\"txtSpecial\" maxlength=\"5\" size=\"5\" value=\"$special\"
>> enabled=\"0\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Description</td>\n";
>>
>> echo " <td align=\"left\" class=\"Text\"><input type=\"text\"
>> name=\"txtDescription\" maxlength=\"200\" size=\"50\"
>> value=\"$description\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\"
>> class=\"Prompt\">Special&nbsp;Type</td>\n";
>>
>> echo " <td align=\"left\" class=\"Selection\">\n";
>>
>> $optPRICE = "";
>>
>> $optDISC = "";
>>
>> $optFROM = "";
>>
>> if ($special_type == "FROM")
>>
>> $optFROM = " SELECTED";
>>
>> elseif ($special_type == "DISC")
>>
>> $optDISC = " SELECTED";
>>
>> else
>>
>> $optPRICE = " SELECTED";
>>
>> echo " <select name=\"cbxSpecial_Type\">\n";
>>
>> echo " <option value=\"PRICE\"$optPRICE>Special Price</option>\n";
>>
>> echo " <option value=\"DISC\"$optDISC>Discount %</option>\n";
>>
>> echo " <option value=\"FROM\"$optFROM>From</option>\n";
>>
>> echo " </select>\n";
>>
>> echo " </td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Price</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><input type=\"text\"
>> name=\"txtPrice\" maxlength=\"20\" size=\"10\"
>> value=\"$price\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> if ($k_subsystem_id == 2)
>>
>> {
>>
>> if (! $new)
>>
>> {
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">Current Photo</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><img
>> src=\"showpic.php?keySystem_Id=2&keyClient_Id=$g_client_id&keySpecial=$special\"></td>\n";
>>
>> echo "</tr>\n";
>>
>> }
>>
>> echo "<tr class=\"Update\">\n";
>>
>> echo " <td align=\"left\" class=\"Prompt\">New Photo</td>\n";
>>
>> echo " <td align=\"left\" class=\"Currency\"><input type=\"file\"
>> name=\"txtPhoto\" size=\"50\"></input></td>\n";
>>
>> echo "</tr>\n";
>>
>> }
>>
>> echo "<tr class=\"Footer\">\n";
>>
>> echo " <td colspan=\"2\">\n";
>>
>> if ($new)
>>
>> {
>>
>> echo " <input type=\"submit\" name=\"cmdAdd\"
>> value=\"Add\">&nbsp;\n";
>>
>> }
>>
>> else
>>
>> {
>>
>> echo " <input type=\"submit\" name=\"cmdUpdate\"
>> value=\"Update\">&nbsp;\n";
>>
>> echo " <input type=\"submit\" name=\"cmdDelete\"
>> value=\"Delete\">&nbsp;\n";
>>
>> }
>>
>> echo " <input type=\"submit\" name=\"cmdCancel\"
>> value=\"Cancel\">\n";
>>
>> echo " </td>\n";
>>
>> echo "</tr>\n";
>>
>> echo "</table>\n";
>>
>> echo "</form>\n";
>>
>> ?>
>>
>>
>>
>> <? include ("body_end.inc"); ?>
>>
>> </html>
>>
>>
>>
>>
>>
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Wed, March 5, 2008 2:08 am, Angelo Zanetti wrote:
> I am implementing a system where when a user is logged in and out that
> a
> date time is set in a database for each action for each used. We can
> then
> trace who logged in a and when.
>
> No what I would like to know is how can I record when a user closes
> the
> browser or the session expires? There is no action for these items. So
> what
> would the best way be to keep a record of this? Would the use of a
> cron job
> be appropriate? I read in the archives that the banks use javascript
> but I
> don't want to go that route.
>
> If anyone has any idea how to do this please let me know, thanks in
> advance.

There is no way to know when they quit/closed the browser or even just
walked away and let the session time out.

But you *CAN* easily log the last time they accessed any page, by
adding something like:

$query = "update user_profile set last_access = now()";
$access = mysql_query($query, $connection);
if (!$access){
  //error handling here
}

So you'll know the last time they actually DID anything, which is
probably more interesting than recording when they closed the browser
if they were looking at some other tab anyway.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Something like this, perhaps:

preg_match('/^((19|20)[0-9]{2})-([0-1]?[0-9])-([0-3]?[0-9])$/',
$input, $date_parts);
var_dump($date_parts);

This doesn't completely rule out bogus dates such as 2008-02-30 however.

I think MySQL would just convert that to MAR 1, 2008 anyway...

But if you want that degree of comparison:

list(,$year, $month, $day) = $date_parts;
$unix = mktime(1, 0, 0, $month, $day, $year);
list($y, $m, $d) = date('Y-m-d', $unix);
if ($year != $y || $month != $m || $day != $d){
  //handle invalid date input here
}

If you do all of that (which is really 5 lines of code) you should be
pretty sure it's a correct/valid date.

On Tue, March 4, 2008 10:12 pm, Larry Brown wrote:
> Thanks,
>
> I ended up doing:
>
> $incomingQuestDatePieces = explode("-", $incomingQuestDate );
>
> if(checkdate($incomingQuestDatePieces[1],$incomingQuestDatePieces[2],
> $incomingQuestDatePieces[0]))
> {
> return true;
> }
> else
> {
> return false;
> }
>
>
> I was just wondering since a lot of people have to verify correct
> format
> of the date when working with mysql that there might be some built in
> that is faster etc.
>
> Thanks though...
>
> On Wed, 2008-03-05 at 14:34 +1100, Chris wrote:
>> Larry Brown wrote:
>> > Its been a long week already... YYYY-MM-DD.
>> >
>> > On Tue, 2008-03-04 at 20:16 -0500, Larry Brown wrote:
>> >> Does anyone know if there is a builtin function for checking the
>> >> formatting of an incoming date to verify it is YYYY/MM/DD. I
>> know how
>> >> to convert between formats but want a quick way to check an
>> incoming
>> >> variable to ensure it will be handled properly by mysqld.
>>
>> I normally provide dropdown fields for each (except the year which
>> is a
>> text-field) and put it together how I need it. Validate each part
>> separately and you're off and racing.
>>
>> If you accept any date you'll probably have to split it up first but
>> the
>> principles will be the same.
>>
>>
>> $date = '0000-00-00';
>> // if they didn't use exactly two dashes? invalid
>> if (substr_count($date, '-') !== 2) {
>> die("Invalid date");
>> }
>>
>> list($year, $month, $day) = explode('-', $date);
>> if (strlen($year) != 4) {
>> die("Invalid year");
>> }
>>
>>
>> and so on.
>>
> --
> Larry Brown <larry.browndimensionnetworks.com>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Doesn't checkdate() do the sanity check for a valid date?

On Fri, 2008-03-07 at 10:08 -0600, Richard Lynch wrote:
> Something like this, perhaps:
>
> preg_match('/^((19|20)[0-9]{2})-([0-1]?[0-9])-([0-3]?[0-9])$/',
> $input, $date_parts);
> var_dump($date_parts);
>
> This doesn't completely rule out bogus dates such as 2008-02-30 however.
>
> I think MySQL would just convert that to MAR 1, 2008 anyway...
>
> But if you want that degree of comparison:
>
> list(,$year, $month, $day) = $date_parts;
> $unix = mktime(1, 0, 0, $month, $day, $year);
> list($y, $m, $d) = date('Y-m-d', $unix);
> if ($year != $y || $month != $m || $day != $d){
> //handle invalid date input here
> }
>
> If you do all of that (which is really 5 lines of code) you should be
> pretty sure it's a correct/valid date.
>
> On Tue, March 4, 2008 10:12 pm, Larry Brown wrote:
> > Thanks,
> >
> > I ended up doing:
> >
> > $incomingQuestDatePieces = explode("-", $incomingQuestDate );
> >
> > if(checkdate($incomingQuestDatePieces[1],$incomingQuestDatePieces[2],
> > $incomingQuestDatePieces[0]))
> > {
> > return true;
> > }
> > else
> > {
> > return false;
> > }
> >
> >
> > I was just wondering since a lot of people have to verify correct
> > format
> > of the date when working with mysql that there might be some built in
> > that is faster etc.
> >
> > Thanks though...
> >
> > On Wed, 2008-03-05 at 14:34 +1100, Chris wrote:
> >> Larry Brown wrote:
> >> > Its been a long week already... YYYY-MM-DD.
> >> >
> >> > On Tue, 2008-03-04 at 20:16 -0500, Larry Brown wrote:
> >> >> Does anyone know if there is a builtin function for checking the
> >> >> formatting of an incoming date to verify it is YYYY/MM/DD. I
> >> know how
> >> >> to convert between formats but want a quick way to check an
> >> incoming
> >> >> variable to ensure it will be handled properly by mysqld.
> >>
> >> I normally provide dropdown fields for each (except the year which
> >> is a
> >> text-field) and put it together how I need it. Validate each part
> >> separately and you're off and racing.
> >>
> >> If you accept any date you'll probably have to split it up first but
> >> the
> >> principles will be the same.
> >>
> >>
> >> $date = '0000-00-00';
> >> // if they didn't use exactly two dashes? invalid
> >> if (substr_count($date, '-') !== 2) {
> >> die("Invalid date");
> >> }
> >>
> >> list($year, $month, $day) = explode('-', $date);
> >> if (strlen($year) != 4) {
> >> die("Invalid year");
> >> }
> >>
> >>
> >> and so on.
> >>
> > --
> > Larry Brown <larry.browndimensionnetworks.com>
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
--
Larry Brown <larry.browndimensionnetworks.com>

attached mail follows:


The + requires at least one character.

The * is "0 or more" characters.

http://php.net/pcre

On Wed, March 5, 2008 9:13 am, It Maq wrote:
> Hi,
>
> I am using that right now and i have don't know how to include blank
> fields. For example if a user does not fill a field in a form i want
> to accept it. I tried the code you posted, for now it is blocking
> blank fields.
>
> Thank you
>
> ----- Original Message ----
> From: Richard Lynch <ceol-i-e.com>
> To: Adil Drissi <adil.drissiyahoo.com>
> Cc: php-generallists.php.net
> Sent: Tuesday, March 4, 2008 3:09:09 PM
> Subject: Re: [PHP] regular expressions question
>
> On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
>> Is there any way to limit the user to a set of characters for
>> example
>> say i want my user to enter any character between a and z (case
>> insensitive). And if the user enters just one letter not belonging
>> to
>> [a-z], this will not be accepted.
>>
>> I tried eregi('[a-z]', $fname) but this allows the user to enter
>> abdg4512kdkdk for example.
>
> What you tried only requires ONE a-z character somewhere in the input.
>
> Try this:
>
> preg_match('^[a-z]+$', $fname);
>
> This will:
> ^ "anchor" the string at the beginning
> [a-z]+ a to z, with at least one letter
> $ "anchor" the string at the end
>
> Note, however, that some people have other characters in their first
> name, such as apostrophe, space, and dash.
>
> Oh, and the digit 3, for "bo3b" who was a programmer on the first
> Apple Macintosh. His parents were hippies, and that really is his
> name...
>
> You may want to obtain a LARGE list of "first names" and run them
> through your validator as a test.
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>
>
> --
> 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

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Thu, February 28, 2008 10:39 am, Nick Gasparro wrote:
> I have an immediate need for a Sr. Developer/Architect; with one of
> Denver's
> Best employers. They are a Web 2.0 company, rapidly growing and very
> profitable. They will pay top compensation and provide relocation
> assistance for the right person.

It is customary for geographically-challenged job postings to include
the location in the subject.

Thanks!

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Hi all

how can we manage session variables when cookies are disabled.

--
Have A pleasant Day
Chetan. D. Rane
Location: India
Contact: +91-9986057255
other ID: chetscoolyahoo.com
            chetranerediffmail.com

attached mail follows:


On Fri, Mar 7, 2008 at 1:15 PM, chetan rane <chetan.d.ranegmail.com> wrote:
> Hi all
>
> how can we manage session variables when cookies are disabled.

    You can send the request with an appended PHPSESSID.

    RTFM: http://us.php.net/session

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


> Date: Fri, 7 Mar 2008 23:45:51 +0530> From: chetan.d.ranegmail.com> To: php-generallists.php.net> Subject: [PHP] SESSIOn when cookies are disabled> > Hi all> > how can we manage session variables when cookies are disabled.> > -- > Have A pleasant Day> Chetan. D. Rane> Location: India> Contact: +91-9986057255> other ID: chetscoolyahoo.com> chetranerediffmail.com
 
 
pass the session id in the URL or add it as a hidden field
 
 
Bastien
_________________________________________________________________

attached mail follows:


Thank you very much its worked great!!!

On Fri, Mar 7, 2008 at 11:50 PM, Bastien Koert <bastien_khotmail.com>
wrote:

>
> > Date: Fri, 7 Mar 2008 23:45:51 +0530> From: chetan.d.ranegmail.com> To:
> php-generallists.php.net> Subject: [PHP] SESSIOn when cookies are
> disabled> > Hi all> > how can we manage session variables when cookies are
> disabled.> > -- > Have A pleasant Day> Chetan. D. Rane> Location: India>
> Contact: +91-9986057255> other ID: chetscoolyahoo.com>
> chetranerediffmail.com
>
>
> pass the session id in the URL or add it as a hidden field
>
>
> Bastien
> _________________________________________________________________
>
>

--
Have A pleasant Day
Chetan. D. Rane
Location: India
Contact: +91-9986057255
other ID: chetscoolyahoo.com
            chetranerediffmail.com

attached mail follows:


hi,
maybe my question is not exactly for php list, but since php IS involved and since you are such a great people, I hope the question will not disturb you :D

I have a project for one electric wholesale store to build a web site. it has to be dynamic, php, database driven web site.
it will have "standard" pages (news, links, about us, history, contact us, contact form, faq, business partners,...) and product catalog. my client wants to have ability to have different prices for the same product for different customers. means, when you come to the site you are going to see "public" prices. after customer logs in he's going to see some products with different price.
customers (only registered ones) will be able to select products and create an order. of course, after he submits, he's going to get confirmation email, and one email will be sent to store etc.

payment is not involved, the store will charge them later, probably monthly or something like that (not part of my project).
even there is not payments or any other sensitive data will be transfered over the internet, I suggested and the store owner accepted to use login to membership area and ordering process SSL.
 
project has administration area too to change content of the site, add/edit/delete (single) products, add/edit/delete customers.
I have to build also script to update products using excel sheet - the easiest way to make update of products for store owner.

I think I covered almost everything. there will be some more stuff, but noghtin "critical" (new customer registration page, manage my profile, order history,...)

now, I didn't have such a big project "on side" ever. and I by default ALWAY suck in calculations how much time I need for a project and what to charge.
I think I need about 120 hrs (3 weeks) to build this baby (without design part).
I need your opinion. is it enough time (yes, I know it depends of how fast I program :D Let's say, average fast :))
and what are fees these days for such a project? I lost track. $75/hr is lowest price today or I can't ask more than $50/hr?

thanks for any advice/help.

-lamp
       
---------------------------------
Never miss a thing. Make Yahoo your homepage.

attached mail follows:


Lamp Lists wrote:

> now, I didn't have such a big project "on side" ever. and I by default
> ALWAY suck in calculations how much time I need for a project and what
> to charge. I think I need about 120 hrs (3 weeks) to build this baby
> (without design part). I need your opinion. is it enough time (yes, I
> know it depends of how fast I program :D Let's say, average fast :))
> and what are fees these days for such a project? I lost track. $75/hr
> is lowest price today or I can't ask more than $50/hr?

You can ask whatever you want as long as your customer thinks it's
reasonable. (not a joke).
Given that you're an individual bidding on a single project, you might
want to consider fixed price instead of time and materials.

As for estimates wrt time and effort - if those were available on a
mailing-list based on about 30 lines of project description, this list
would be full of project managers, all with desperate needs to estimate
how long <something> takes. :-)

/Per Jessen, Zürich

attached mail follows:


I have this:

<?php if (trim($_SESSION['nowtoctype']) == 'thistype')

{print '<a href="page1.php">page1</a>';}else{print '<a href="
page2.php">page2</a>';} ?>

I will get the error:

Notice: Undefined index: nowtoctype in ...

If the variable has not yet been defined...

Is there a way to check if this var is already defined? ... (and then I can
define it - if not)

--
Thanks - RevDave
Cool hosting4days . com
[db-lists]

attached mail follows:


On Fri, Mar 7, 2008 at 2:59 PM, revDAVE <Coolhosting4days.com> wrote:
> I have this:
>
> <?php if (trim($_SESSION['nowtoctype']) == 'thistype')
>
> {print '<a href="page1.php">page1</a>';}else{print '<a href="
> page2.php">page2</a>';} ?>
>
> I will get the error:
>
> Notice: Undefined index: nowtoctype in ...

    Check out isset(): http://php.net/isset

<?php
    if(isset($_SESSION['nowtoctype']) && trim($_SESSION['nowtoctype'])
== 'thistype') {
        echo "<a href=\"page1.php\">Page 1</a>\n";
    } else {
        echo "<a href=\"page2.php\">Page 2</a>\n";
    }
?>

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

attached mail follows:


        Posting Summary for PHP-General List
        Week Ending: Friday, 7 March, 2008

        Messages | Bytes | Sender
        --------------------+--------------------+------------------
        378 (100%) 575642 (100%) EVERYONE
        38 (10.1%) 55696 (9.7%) Richard Lynch <ceo at l-i-e dot com>
        27 (7.1%) 25479 (4.4%) tedd <tedd dot sperling at gmail dot com>
        25 (6.6%) 24503 (4.3%) Daniel Brown <parasane at gmail dot com>
        16 (4.2%) 23389 (4.1%) Jochem Maas <jochem at iamjochem dot com>
        14 (3.7%) 12495 (2.2%) Chris <dmagick at gmail dot com>
        14 (3.7%) 27449 (4.8%) Shawn McKenzie <nospam at mckenzies dot net>
        12 (3.2%) 21000 (3.6%) Eric Butera <eric dot butera at gmail dot com>
        9 (2.4%) 12466 (2.2%) Wolf <lonewolf at nc dot rr dot com>
        9 (2.4%) 30276 (5.3%) Pieter du Toit <pieter at lpwebdesign dot co dot za>
        9 (2.4%) 19573 (3.4%) Larry Brown <larry dot brown at dimensionnetworks dot com>
        9 (2.4%) 13238 (2.3%) Stut <stuttle at gmail dot com>
        8 (2.1%) 12328 (2.1%) Thiago Pojda <thiago dot pojda at softpartech dot com dot br>
        8 (2.1%) 19894 (3.5%) Ray Hauge <ray dot hauge dot lists at gmail dot com>
        7 (1.9%) 14455 (2.5%) Nathan Nobbe <quickshiftin at gmail dot com>
        7 (1.9%) 9108 (1.6%) Jim Lucas <lists at cmsws dot com>
        7 (1.9%) 16041 (2.8%) Svevo Romano <svevo at svevoromano dot it>
        6 (1.6%) 4078 (0.7%) Stephen <stephen-d at rogers dot com>
        6 (1.6%) 7143 (1.2%) Aschwin Wesselius <aschwin at illuminated dot nl>
        6 (1.6%) 9885 (1.7%) Jason Pruim <japruim at raoset dot com>
        5 (1.3%) 4865 (0.8%) Steve Finkelstein <sf at stevefink dot net>
        5 (1.3%) 9204 (1.6%) Richard <php_list at ghz dot fr>
        5 (1.3%) 8489 (1.5%) Zareef Ahmed <zareef at zareef dot net>
        5 (1.3%) 12086 (2.1%) Angelo Zanetti <angelo at elemental dot co dot za>
        4 (1.1%) 4845 (0.8%) Colin Guthrie <gmane at colin dot guthr dot ie>
        4 (1.1%) 9888 (1.7%) David Sveningsson <ext at sidvind dot com>
        4 (1.1%) 6709 (1.2%) Zoltán Németh <znemeth at alterationx dot hu>
        4 (1.1%) 2936 (0.5%) Greg Donald <gdonald at gmail dot com>
        4 (1.1%) 3273 (0.6%) Richard Heyes <richardh at phpguru dot org>
        4 (1.1%) 5909 (1%) Robert Cummings <robert at interjinn dot com>
        4 (1.1%) 6429 (1.1%) Adrian Walls <awalls at kpoint dot co dot uk>
        4 (1.1%) 3747 (0.7%) movies at biblescramble dot com
        4 (1.1%) 5956 (1%) Nathan Rixham <nrixham at gmail dot com>
        3 (0.8%) 3089 (0.5%) gary liang <figo2476 at hotmail dot com>
        3 (0.8%) 5751 (1%) Skip Evans <skip at bigskypenguin dot com>
        3 (0.8%) 1448 (0.3%) Jay Blanchard <jblanchard at pocket dot com>
        3 (0.8%) 2596 (0.5%) Bastien Koert <bastien_k at hotmail dot com>
        3 (0.8%) 3725 (0.6%) chetan rane <chetan dot d dot rane at gmail dot com>
        3 (0.8%) 10005 (1.7%) Andrés Robinet <agrobinet at bestplace dot biz>
        3 (0.8%) 5954 (1%) Bojan Tesanovic <btesanovic at gmail dot com>
        2 (0.5%) 2291 (0.4%) Adil Drissi <adil dot drissi at yahoo dot com>
        2 (0.5%) 1688 (0.3%) Louie Miranda <lmiranda at gmail dot com>
        2 (0.5%) 2652 (0.5%) Ben Edwards <funkytwig at gmail dot com>
        2 (0.5%) 1505 (0.3%) Per Jessen <per at computer dot org>
        2 (0.5%) 1515 (0.3%) Brice <brice dot favre at gmail dot com>
        2 (0.5%) 1131 (0.2%) David Giragosian <dgiragosian at gmail dot com>
        2 (0.5%) 2784 (0.5%) Ford, Mike <M dot Ford at leedsmet dot ac dot uk>
        2 (0.5%) 1313 (0.2%) Al <news at ridersite dot org>
        2 (0.5%) 1009 (0.2%) Ron Piggott <ron dot php at actsministries dot org>
        2 (0.5%) 1550 (0.3%) Shelley <myphplist at gmail dot com>
        2 (0.5%) 5783 (1%) Rahul <rahul986 at gmail dot com>
        2 (0.5%) 2278 (0.4%) Dave M G <martin at autotelic dot com>
        1 (0.3%) 540 (0.1%) Rahul <rahul986 at gmail dot com>
        1 (0.3%) 3042 (0.5%) Andrés Robinet <agrobinet at bestplace dot biz>
        1 (0.3%) 1547 (0.3%) Zeshan Uddin <uzeshan at googlemail dot com>
        1 (0.3%) 2002 (0.3%) It Maq <itmaqurfe at yahoo dot com>
        1 (0.3%) 2038 (0.4%) M dot Sokolewicz <tularis at php dot net>
        1 (0.3%) 3045 (0.5%) Traina Vigoren <abstrict at amfengshui dot com>
        1 (0.3%) 2358 (0.4%) Lamp Lists <lamp dot lists at yahoo dot com>
        1 (0.3%) 470 (0.1%) Mark Wiesemann <wiesemann at php dot net>
        1 (0.3%) 882 (0.2%) Manuel Lemos <mlemos at acm dot org>
        1 (0.3%) 326 (0.1%) John Papas <jspapas at gmail dot com>
        1 (0.3%) 2990 (0.5%) Deroberts Chorney <nominative at bmn dot com>
        1 (0.3%) 2011 (0.3%) Peter Ford <pete at justcroft dot com>
        1 (0.3%) 293 (0.1%) Joey <Joey at Web56 dot Net>
        1 (0.3%) 1973 (0.3%) Jonathan Pitcher <jonathan dot pitcher at gmail dot com>
        1 (0.3%) 3001 (0.5%) Dunwoody Poetker <ruffians at csc dot com>
        1 (0.3%) 1778 (0.3%) Frank Arensmeier <frank dot arensmeier at nikehydraulics dot se>
        1 (0.3%) 538 (0.1%) revDAVE <Cool at hosting4days dot com>
        1 (0.3%) 2505 (0.4%) Casey <heavyccasey at gmail dot com>
        1 (0.3%) 494 (0.1%) Edward Kay <edward at labhut dot com>
        1 (0.3%) 636 (0.1%) Dani Castaños <danitao dot mailists at gmail dot com>
        1 (0.3%) 1289 (0.2%) David Robley <robleyd at aapt dot net dot au>
        1 (0.3%) 2250 (0.4%) Nuno Mendes <nmendes at dataworks dot pt>
        1 (0.3%) 1656 (0.3%) Jed Reynolds <lists at bitratchet dot com>
        1 (0.3%) 611 (0.1%) Rick Pasotto <rick at niof dot net>
        1 (0.3%) 10027 (1.7%) PostTrack [Dan Brown] <listwatch-php-general at pilotpig dot net>
        1 (0.3%) 2955 (0.5%) Satyam <Satyam at satyam dot com dot ar>
        1 (0.3%) 1173 (0.2%) Erik SJMN <erik dot sjmn at gmail dot com>
        1 (0.3%) 1031 (0.2%) Samuel Vogel <samy-delux at gmx dot de>
        1 (0.3%) 688 (0.1%) Richard S dot Crawford <rscrawford at mossroot dot com>
        1 (0.3%) 3462 (0.6%) Marcus Boerger <helly at php dot net>
        1 (0.3%) 2523 (0.4%) Daevid Vincent <daevid at daevid dot com>
        1 (0.3%) 3424 (0.6%) Sofia Jacob (CA) <jacobsofia at yahoo dot ca>
        1 (0.3%) 1347 (0.2%) Paul Scott <pscott at uwc dot ac dot za>
        1 (0.3%) 1123 (0.2%) Danny Brow <maillist at fullmotions dot com>
        1 (0.3%) 762 (0.1%) Sancar Saran <sancar dot saran at evodot dot com>
        1 (0.3%) 2974 (0.5%) Cameron Gaona <venepuncture at anthems dot com>
        1 (0.3%) 438 (0.1%) Brady Mitchell <mydarb at gmail dot com>
        1 (0.3%) 259 (0%) JJB <onephatcat at earthlink dot net>
        1 (0.3%) 1940 (0.3%) Keikonium <Keikonium at hotmail dot com>
        1 (0.3%) 2342 (0.4%) Warren Vail <warren at vailtech dot net>

NOTE: Numbers may not add up to 100% due to protection of names and addresses upon request.

DISCLAIMER: If you want your email address omitted from future weekly reports,
please email me privately at parasanegmail.com and it will be removed.

attached mail follows:


Hey - - -- - -- --

I keep a profile of a user's rights and responsibilities in tables.
Since this profile defines what a user can do in the system I am
designing, I'd like to build a JavaScript menu navigation scheme. I
need it to be driven programmatically, because the Admin users can
add and remove tasks to the system or to a given user at-will.

I already built a similar thing using CSS-only menus, but it just
wasn't aesthetically flexible enough. I am exploring other options,
but I am wondering if any of you have done something similar and have
any samples or advice.

Ken

attached mail follows:


Was just upgrading to 5.2.5 and used the same configure line as I used
for 5.2.0. Got the following notice:

"Notice: Following unknown configure options were used:

--enable-pic
--with-dom
--with-png
--with-xml
--enable-track-vars
--enable-trans-sid
--enable-yp
--enable-mbstr-enc-trans
--enable-dio
--enable-mcal
--with-jpeg"

Safe to assume those were deprecated?