php-general Digest 21 Mar 2012 02:00:27 -0000 Issue 7736
Topics (messages 317141 through 317151):
Re: Sunset/Sunrise
317141 by: Andrew Ballard
317149 by: Tedd Sperling
317150 by: Andrew Ballard
Re: Graphing
317142 by: Ross Hansen
php upload does not work proper, ["tmp_name"] and other are missing in $_FILES
317143 by: Meike Stone
317144 by: Matijn Woudt
317145 by: Meike Stone
Bug zlib.output_compression not normal work in IIS7.5
317146 by: СÓãϺ
PHP 5.3.2 on IIS Fast CGI Timeout error
317147 by: Jay Blanchard
Re: PHP 5.3.2 on IIS Fast CGI Timeout error (SOLVED)
317148 by: Jay Blanchard
Re: Getting knotted with quotes encoding - (one possible solution)
317151 by: tamouse mailing lists
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 ---
On Tue, Mar 20, 2012 at 9:23 AM, Tedd Sperling <[email protected]> wrote:
> Hi gang:
>
> What's wrong with this?
>
> echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(),
> SUNFUNCS_RET_STRING, 42.57, 84.3320, 90, -5);
> echo('<br>');
> echo date("D M d Y"). ', sunset time : ' .date_sunset(time(),
> SUNFUNCS_RET_STRING, 42.57, 84.3320, 90, -5);
>
> It gives exactly the wrong time -- Sunset is reported as Sunrise and vice
> versa. What's up?
>
> Thanks,
>
> tedd
tedd,
I think you used the incorrect longitude. Did you want a location in
northern China (as you entered above) or near Dansville, MI (in which
case I believe your longitude above should be negative rather than
positive)?
http://maps.google.com/maps?q=42.57,84.3320&hl=en&sll=42.57,-84.332&sspn=0.023008,0.038581&t=m&z=8
http://maps.google.com/maps?q=42.57,-84.3320&hl=en&sll=42.554092,-84.324188&sspn=0.736459,1.234589&t=m&z=15
Andrew
--- End Message ---
--- Begin Message ---
On Mar 20, 2012, at 9:50 AM, Andrew Ballard wrote:
> On Tue, Mar 20, 2012 at 9:23 AM, Tedd Sperling <[email protected]>
> wrote:
>> Hi gang:
>>
>> What's wrong with this?
>>
>> echo date("D M d Y"). ', sunrise time : ' .date_sunrise(time(),
>> SUNFUNCS_RET_STRING, 42.57, 84.3320, 90, -5);
>> echo('<br>');
>> echo date("D M d Y"). ', sunset time : ' .date_sunset(time(),
>> SUNFUNCS_RET_STRING, 42.57, 84.3320, 90, -5);
>>
>> It gives exactly the wrong time -- Sunset is reported as Sunrise and vice
>> versa. What's up?
>>
>> Thanks,
>>
>> tedd
>
> tedd,
>
> I think you used the incorrect longitude. Did you want a location in
> northern China (as you entered above) or near Dansville, MI (in which
> case I believe your longitude above should be negative rather than
> positive)?
>
> http://maps.google.com/maps?q=42.57,84.3320&hl=en&sll=42.57,-84.332&sspn=0.023008,0.038581&t=m&z=8
>
> http://maps.google.com/maps?q=42.57,-84.3320&hl=en&sll=42.554092,-84.324188&sspn=0.736459,1.234589&t=m&z=15
>
> Andrew
Andrew:
That's what I get for not checking it myself. I was assured by one of my
students that was our correct lat/long. Boy, will he hear from me -- he's going
to find his next assignment in China. :-)
Thanks,
tedd
_____________________
[email protected]
http://sperling.com
--- End Message ---
--- Begin Message ---
On Tue, Mar 20, 2012 at 6:00 PM, Tedd Sperling <[email protected]> wrote:
> That's what I get for not checking it myself. I was assured by one of my
> students that was our correct lat/long. Boy, will he hear from me -- he's
> going to find his next assignment in China. :-)
>
> Thanks,
>
> tedd
That's the spirit! Truly world-class education!
Andrew
--- End Message ---
--- Begin Message ---
Thanks Everyone for your responses.
I apologize for not responding sooner however i was away from the computer and
was not able to check my email or look into this further.
I am quite interested in a few of them so i will do further testing and
research. I was also hoping to learn how to create them my self but that is
more just because i enjoy trying to learn.
Regards
Ross
> CC: [email protected]
> From: [email protected]
> Date: Sun, 18 Mar 2012 11:27:23 -0400
> To: [email protected]
> Subject: Re: [PHP] Graphing
>
>
>
> On 2012-03-18, at 9:33 AM, Ross Hansen <[email protected]> wrote:
>
> > Hey all,
> >
> > I have been working with php for a few years but mostly simple stuff. I'm
> > now looking at doing some graphing but have no experience with dynamic
> > images.
> >
> > I have never used imagecreate but have seen one example of it and not sure
> > if it is really what i'm after.
> > It needs to graph changing data from a mysql db.
> > I also understand php might not be the best option due to the server load.
> >
> > Just want to get peoples thoughts and suggestions.
> > Was so looking at jquery.
> >
> > Looking forward your responses.
> >
> > Regards
> > Ross
> >
>
> If you are looking at a js type dataviz, check out kendo-ui ( built on jquery
> )
>
> If you want php based then there are tons of options (YMMV)
>
> - phpplot
> - jgraph
> - etc ( a quick google will give you more)
>
> Bastien
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Hello,
I try the upload files, but in "tmp_name" and other variables are
missing in $_FILES.
I use php 5.3.8 on SLES11SP2
I can repeat this with:
===================================================
<?php
if(isset($_FILES)) {
var_dump($_FILES);
}
?>
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="/i3.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
===================================================
The $_FILES shows only:
array(1) { ["userfile"]=> array(1) { ["name"]=> string(14) "ask_script.xml" } }
I traced (strace) the apache process, and I saw, that a temporary
file was opened, the text from the file written and than later
unlinked.
What can be the problem?
Kindly regards
--- End Message ---
--- Begin Message ---
On Tue, Mar 20, 2012 at 4:33 PM, Meike Stone <[email protected]> wrote:
> Hello,
>
> I try the upload files, but in "tmp_name" and other variables are
> missing in $_FILES.
> I use php 5.3.8 on SLES11SP2
>
> I can repeat this with:
> ===================================================
> <?php
> if(isset($_FILES)) {
> var_dump($_FILES);
> }
> ?>
> <!-- The data encoding type, enctype, MUST be specified as below -->
>
> <form enctype="multipart/form-data" action="/i3.php" method="POST">
>
> <!-- MAX_FILE_SIZE must precede the file input field -->
>
> <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
>
> <!-- Name of input element determines name in $_FILES array -->
>
> Send this file: <input name="userfile" type="file" />
>
> <input type="submit" value="Send File" />
>
> </form>
> ===================================================
>
> The $_FILES shows only:
> array(1) { ["userfile"]=> array(1) { ["name"]=> string(14) "ask_script.xml" }
> }
>
> I traced (strace) the apache process, and I saw, that a temporary
> file was opened, the text from the file written and than later
> unlinked.
>
> What can be the problem?
>
>
>
> Kindly regards
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
First of all, check your apache log files for any hints. There's
probably a warning/error in there that explains why.
If not, check your php.ini settings, there are a few settings that can
affect uploads (see [1]).
- Matijn
[1] http://nl3.php.net/manual/en/ini.core.php#ini.sect.file-uploads
--- End Message ---
--- Begin Message ---
>
> First of all, check your apache log files for any hints. There's
> probably a warning/error in there that explains why.
I switched to "LogLevel debug" but in error_log is nothing found,
the access_log showes only:
192.168.1.89 - - [20/Mar/2012:16:43:53 +0100] "POST /i3.php HTTP/1.1"
200 539 "http://172.16.1.170/i3.php" "Mozilla/5.0 (Windows NT 5.1;
WOW64; rv:11.0) Gecko/20100101 Firefox/11.0"
> If not, check your php.ini settings, there are a few settings that can
> affect uploads (see [1]).
>
> [1] http://nl3.php.net/manual/en/ini.core.php#ini.sect.file-uploads
Yes, I know this settings and checked this and disabled suhosin too.
Nothing helped.
I did this before "stracing" ...
Thanks Meike
--- End Message ---
--- Begin Message ---
How I do fix it ?
https://bugs.php.net/bug.php?id=61434
ID: 61434 User updated by: info at ongod dot org Reported
by: info at ongod dot org Summary: zlib.output_compression
not normal work in IIS7.5 Status: Not a bug Type:
Bug Package: Zlib related Operating System: windows2008R2x64
PHP Version: 5.4.0 Block user comment: N Private report: N New
Comment: it is Should be clean code for check. php5.4 not normal work. but
php5.3.10 normal work in the same server. who tell me why this ?
http://www.ongod.org/test/phpinfo.php Web page compressed? No Compression
type? none Size, Markup (bytes) 83,611 Size, Compressed (bytes) 0
Compression % 0.0 php5.3.10 http://mail.ipv6china.com/phpinfo.php Web page
compressed? Yes Compression type? gzip Size, Markup (bytes)
87,124 Size, Compressed (bytes) 13,730 Compression % 84.2 check from
http://www.gidnetwork.com/tools/gzip-test.php Previous Comments:
------------------------------------------------------------------------
[2012-03-19 14:14:54] [email protected] ok, not a bug but a support issue. @info
at ongod dot org Please ask further support on the PHP general mailing list or
any other support channel, thanks!
------------------------------------------------------------------------
[2012-03-19 14:10:56] [email protected] I cannot reproduce the issue, tried with the
latest php 5.4 and IIS7. IIS7 has compression turned off and the php.ini has
both zlib.output_compression=on and zlib.output_compression_level=-1 set. The
page is merely a phpinfo() page. Here the simple ping pong: GET /i.php
HTTP/1.1 Host: localhost Connection: keep-alive Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko)
Chrome/17.0.963.79 Safari/535.11 Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch Accept-Language:
de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4 Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.3 HTTP/1.1 200 OK Content-Type: text/html
Content-Encoding: gzip Vary: Accept-Encoding Server: Microsoft-IIS/7.5
X-Powered-By: PHP/5.4.1RC1-dev Date: Mon, 19 Mar 2012 14:00:09 GMT
Content-Length: 6182 The output compression seems to work. @info at ongod dot
org Could you please try such a simple page scenario and post the
request/response headers?
------------------------------------------------------------------------
[2012-03-19 14:01:26] nacin at wordpress dot org I can confirm that WordPress
3.3.1 does not set zlib.output_compression. Looks like WP never has.
------------------------------------------------------------------------
[2012-03-19 11:40:20] info at ongod dot org Security reasons, I would also send
an email to you.
------------------------------------------------------------------------
[2012-03-19 11:25:40] [email protected] zlib.output_compression can be disabled at
runtime at later stage in PHP 5.4. I'd probably be lost on a Windows box, so I
don't think I could help you there.
------------------------------------------------------------------------ The
remainder of the comments for this report are too long. To view the rest of the
comments, please view the bug report online at
https://bugs.php.net/bug.php?id=61434
--- End Message ---
--- Begin Message ---
Good afternoon PHP gurus,
I am trying to troubleshoot a problem on a Windows server (*UGH*). This
is the error -
The FastCGI Handler was unable to process the request.
------------------------------------------------------------------------
Error Details:
* The FastCGI process exceeded configured activity timeout
* Error Number: 258 (0x80070102).
* Error Description: The wait operation timed out.
HTTP Error 500 - Server Error.
Internet Information Services (IIS)
Here is the code it appears to be choking on -
/* open the file for reading and/or writing */
$csvFile = fopen(CSV_FILE, "rb");
$csvTemp = fopen(CSV_TEMP_FILE, "wb");
if(!$csvTemp) {
echo 'failed tp open '.CSV_TEMP_FILE;
}
/* create the edit vehicle info */
/* create a stock number for this vehicle */
$vinPart = substr($_POST['vin-number'], -6);
$stockNumber = 'EC'.$vinPart;
/* create a line to be inserted into the .csv file */
$csvContent = $stockNumber.',';
$csvContent .= mysql_real_escape_string($_POST['vehUser']).',';
$csvContent .= mysql_real_escape_string($_POST['vmake']).',';
$csvContent .= mysql_real_escape_string($_POST['vmodel']).',';
$csvContent .= mysql_real_escape_string($_POST['vyear']).',';
$csvContent .=
mysql_real_escape_string($_POST['vin-number']).',';
$csvContent .= mysql_real_escape_string($_POST['vprice']).',';
$csvContent .=
mysql_real_escape_string($_POST['vdescription'])."\r\n";
/* loop through and write edited lines back in while
maintaining non-edited lines */
while(!FEOF($csvFile)) {
/* get current line information */
$originalLineArray = fgetcsv($csvFile, 4096, ',');
/* test and replace as required */
if(is_array($originalLineArray)) {
if($stockNumber == $originalLineArray[0]) {
fwrite($csvTemp, $csvContent);
} else {
$currentLine = implode(",", $originalLineArray);
$currentLine = $currentLine."\r\n";
fwrite($csvTemp, $currentLine);
}
}
}
/* close the files */
fclose($csvFile);
fclose($csvTemp);
/* rename the temp file */
rename(CSV_TEMP_FILE, CSV_FILE);
Anyone have any clue why this might be happening? I have followed the
events using Process Monitor which doesn't complain at all, yet the temp
file gets created but never written to. I have been all over the web for
a couple of hours now with no clue as to what is going on. I'd really
appreciate any hints or tips.
--- End Message ---
--- Begin Message ---
[snip]
..the craziness of it all
[/snip]
Found out that the PostGreSQL .dll was not loaded and that the server had been
configured to not give up any errors regardless of how I set error reporting.
Reconfigured the server and restarted it. Viola'! It all works now.
--- End Message ---
--- Begin Message ---
On Mon, Mar 19, 2012 at 10:43 AM, Arno Kuhl <[email protected]> wrote:
> -----Original Message-----
> From: tamouse mailing lists [mailto:[email protected]]
> Sent: 19 March 2012 10:28 AM
> To: [email protected]
> Subject: Re: [PHP] Getting knotted with quotes encoding - (one possible
> solution)
>
> On Sun, Mar 18, 2012 at 10:19 PM, Tamara Temple
> <[email protected]> wrote:
>> On Tue, 13 Mar 2012 16:35:44 +0200, Arno Kuhl <[email protected]> sent:
>>
>>> From: Ashley Sheridan [mailto:[email protected]]
>>> Sent: 13 March 2012 03:25 PM
>>> To: [email protected]; [email protected]
>>> Subject: Re: [PHP] Getting knotted with quotes encoding
>>>
>>>
>>> Arno Kuhl <[email protected]> wrote:
>>>
>>>> I've been battling with quotes encoding when outputting javascript
>>>> with php.
>>>> It can't be unique, so I'm hoping someone has a working solution
>>>> they're willing to share.
>>>>
>>>> The following works perfectly as long as there aren't any single
>>>> quotes in the link text:
>>>> echo "<span onclick=\"insertLink('$sUrl','$sTitle')\"
>>>> class='linkSel'>$sTitle</span>";
>>>>
>>>> if $sTitle has the value What's new it outputs:
>>>> <span
>>>> onclick="insertLink('article/whats-new.html','What's
>>>> new')" class='linkSel'>What's new</span>
>>>>
>>>> It displays fine, but javascript complains with:
>>>> Expected ')' linkmanager.php Line:525 Char:63
>>>>
>>>>
>>>> So I fix this by swapping the double and single quotes around:
>>>> echo "<span onclick='insertLink(\"$sUrl\",\"$sTitle\")'
>>>> class='linkSel'>$sTitle</span>";
>>>>
>>>> Now for that specific link it outputs:
>>>> <span
>>>> onclick='insertLink("article/whats-new.html","What's
>>>> new")' class='linkSel'>What's new</span> And javascript is happy.
>>>>
>>>> But elsewhere there's a link Fred "Buster" Cox and it outputs:
>>>> <span
>>>> onclick='insertLink("article/fred-buster-cox.html","Fred
>>>> "Buster" Cox")' class='linkSel'>Fred "Buster"
>>>> Cox</span>
>>>>
>>>> Again it displays fine, but javascript complains with:
>>>> Expected ')' linkmanager.php Line:743 Char:77
>>>>
>>>>
>>>> So it looks like I can't have links that include single quotes and
>>>> double quotes, only one or the other.
>>>>
>>>> One work-around I thought of was to convert any link texts that
>>>> included double quotes into single quotes when the content is
>>>> posted, and it would then be displayed with single quotes even
>>>> though the user entered double quotes. It's far from ideal but it
>>>> would work, though I can think of a few situations where it would be
>>>> quite confusing to the reader. Are there any other solutions that
>>>> would allow both types of quotes without any conversions?
>>>>
>>>> Cheers
>>>> Arno
>>>>
>>>>
>>>> --
>>>
>>>
>>> You aren't escaping the quotes correctly when they go into your output.
>>> You're escaping them for html not javascript. Javascript (like php)
>>> escapes single quotes inside a single quote string with a back slash.
>>>
>>>
>>> Thanks,
>>> Ash
>>> http://ashleysheridan.co.uk
>>> ---------
>>>
>>> Thanks for that Ashley.
>>> You're right about the encoding.
>>> I had a line prior to that:
>>> $sTitle = htmlentities($title, ENT_QUOTES, 'ISO-8859-1',
>>> FALSE); Which encoded the quotes.
>>>
>>>
>>> I couldn't find anything so made a function, which might be useful
>>> for others.
>>> It’s a first shot, I'm sure there are ways to improve performance.
>>> I also changed the encoding to exclude single quotes.
>>> (I'm sure the indenting will get screwed up in the mail)
>>>
>>>
>>> $sTitle = fixSingleQuotes(htmlentities($title, ENT_COMPAT,
>>> 'ISO-8859-1', FALSE));
>>>
>>> .....
>>>
>>>
>>> /////////////////////////////////////////////////////////////////////
>>> /////////// // convert single quotes to curly quotes, xml compliant
>>> // assumes apostrophes must be between 2 alpha chars // and any other
>>> ' is a single quote // ‘ = left single quote // ’ = right
>>> single quote and apostrophe function fixSingleQuotes($sText) {
>>> if (strpos($sText, "'") !== FALSE) {
>>> // there are quotes to convert
>>> $bOpenQuote = FALSE;
>>> $arrAlpha = explode(' ', "a b c d e f g h i j k l m n
>>> o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V
>>> W X Y Z");
>>> $arrText = str_split($sText);
>>> while (($pos = strpos($sText, "'")) !== FALSE) {
>>> if ($pos == 0) {
>>> // must be an open quote in first pos
>>> $sText = "‘".substr($sText, 1);
>>> $bOpenQuote = TRUE;
>>> } else {
>>> if (in_array($arrText[$pos-1],
>>> $arrAlpha)
>>> AND in_array($arrText[$pos+1], $arrAlpha)) {
>>> // apostrophe
>>> $quote = "’";
>>> } else {
>>> // quote
>>> if (!$bOpenQuote) {
>>> $quote = "‘";
>>> $bOpenQuote = TRUE;
>>> } else {
>>> $quote = "’";
>>> $bOpenQuote = FALSE;
>>> }
>>> }
>>> $sText = substr($sText, 0,
>>> $pos).$quote.substr($sText, $pos+1);
>>> }
>>> }
>>> }
>>> return ($sText);
>>>
>>> } //fixSingleQuotes()
>>>
>>>
>>>
>>> Cheers
>>> Arno
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>>> http://www.php.net/unsub.php
>>>
>>>
>>
>>
>> This is interesting. I wasn't aware that javascript reencoded html
>> entities in this way.
>>
>> I'm wondering, though, wouldn't a call to addslashes work in this case?
>
> Wow, no it wouldn't. At least not the way it needs to to be more universal. I
> spent quite a bit of time pondering this and testing things, and finally came
> up with this writeup:
> http://wiki.tamaratemple.com/Technology/HandlingQuotesInJavascript
>
> Given the final outcome of needing to write a base64 codec for javascript,
> perhaps Arno's solution above it better?
> ----
>
> Hi tamouse
>
> Interesting article. I referenced
> http://www.dwheeler.com/essays/quotes-in-html.html which you also might find
> useful for this topic. David Wheeler deals generally with converting double
> and single quotes to improve style while remaining compliant across as many
> areas as possible, whereas I was specifically focussed on replacing single
> quotes with something else to overcome the javascript encoding problem (as
> was your article). It's worth reading why he suggests avoiding things like
> "
>
>
> Hi Tamara
>
> Be careful of using that code which was a first attempt, (1) it has a bug,
> (2) the rules are too simplistic - it covers most cases, but to cover that
> last bit requires a LOT more code, plus there are 2 conditions that just
> can't be handled as far as I can see, and (3) it only works for English.
>
> Firstly the pos pointer goes out of sync between the string and the array as
> soon as the string is expanded with the first conversion, so the array needs
> to be recreated each time, by moving the line $arrText = str_split($sText);
> inside the while loop.
>
> Secondly the rules of that function don't handle texts like: "rock 'n roll",
> "Cass' ball", " 'twas the...", "1's and 2's", 3"6' .
>
> I rewrote the function to fix the bug and handle some of the extra cases, so
> it now works for "Cass' ball" (as long as it's not inside a single quote set,
> as in " he said 'this is Cass' ball' ") and it works for "rock 'n roll" (with
> a special test for " 'n ") and for "1's and 2's" and 3"6'. In fact it does
> work for " he said 'this is Cass' ball' " and " 'twas the..." as long as
> there aren't any following single quotes sets, but to do that required an
> extra pass so the performance drops (I define single quote sets as open/close
> single quotes excluding apostrophes). I think you can't come up with a
> function to handle an unreal string such as " he said 'these are Cass' balls'
> and she said 'these are Jess' cats' and 'twas the night before he said 'boo'
> to her 'cause Jess' cat is 'mad' red ".
>
> This was quite an interesting exercise, and could make quite an interesting
> competition to see who could come up with the most efficient function to
> handle the most cases correctly. I think the main rule to follow is that in
> almost every case where the text is impossible to correctly convert it's also
> probably very difficult for users to read, so maybe you can assume that the
> most difficult cases won't occur in the real world.
>
> Cheers
> Arno
>
Thanks for that link, Arno, I'll check into and possibly modify my
article. The article was an experiment to see how these things worked.
I would definitely agree that the first attempt was a failure, not
just because of possible bugs, but more because it just did not do the
job AT ALL. (I guess I should emphasize that in the article.)
The base64 version seems like it might be the most robust in terms of
getting data where it needs to go, as long as you can also deal with
the various character encoding issues (which is not trivial!!). I
don't think there is really a good general solutions to this at hand.
--- End Message ---