I bit my head off when I was trying to increase the upload_max_filesize on my new MAC OSX 10.7.2.
Finally it works when I create the /etc/php.ini file based on /etc/php.ini.default
sudo cp /etc/php.ini.default /etc/php.ini
and then restarted the httpd service.
I used the code below in a page of lots of checkboxes that display ajax requests, it worked
pretty good avoiding muiltiples requests for heavy users.
The secret here is the function beforeSend that is implements in jQuery 1.4.x and the attribute queue.
var filters = {
queue : [],
hideLoading : function(){
jQuery('#loading').hide();
},
showLoading : function(){
jQuery('#loading').show();
},
loadPage : function(){
try{
ListFilter.showLoading();
$j.ajax({
type: "POST",
url: $j('#form').attr('action'),
data: $j('#form').serialize(),
async: true,
dataType: "html",
beforeSend: function( xhr ) {
I would like to check the filesize in an application before I download it.
So, I found this code http://snipplr.com/view/29/get-remote-filesize/ and I changed it a little bit in order to make it more readable.
function remotefilesize($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE); // 200
$filesize = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); //filesize
curl_close($ch);
if( 200 != $status )
throw new Exception('File not found!');
return $filesize;
}
printf('PHP logo has %s bytes', remotefilesize("http://br2.php.net/images/php.gif") );
Have you ever had your server knocked down by hight load?
This is a very simple tip that you can improve for your needs.
The normal situation when it happend is the server load go up and stop to response. It's normal when the website is being attacked by lots of bots or bad users like a DDOS. We know the problem is so many connection but we normally can't do nothing in this moment.
In order to prevent the server down, I found a very simple way in application side.
I use this code in my application controller and return status 503 to the requester.
# return status 503 when the load is so high
$load = sys_getloadavg();
if ($load[0] > 50) {
header('HTTP/1.1 503 Too busy, try again later');
die('Server too busy. Please try again later.');
}
If you are using the getDistance method provided by Geogrphical Template in Doctrine and got this error:
UPDATE: IT WAS FIXED, CHECK IT OUT AT http://www.doctrine-project.org/jira/browse/DC-524
500 | Internal Server Error | Doctrine_Connection_Pgsql_Exception
SQLSTATE[22003]: Numeric value out of range: 7 ERROR: input is out of range
You probably have the same problem that I got today..
I'm using NUMERIC on column type with precision 10, but the problem is not in the column latitude and longitude, it´s on calculation.
To resolve this problem I made a casting inside of ACOS function calculation, I tested it only in postgresql.
My DQL used to get all hotels around 3 kilometers of hotel id 189646