algumas coisas do meu ponto de vista.

How to increase the upload_max_filesize var on MAC OSX

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.

Simple way to use Queue requests in jQuery

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 ) {
        
  

How to get the filesize on remote calls

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") );

Symfony, How to prevent your site from being knocked down by ddos

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.');
}

mpStarRatingPlugin - Nice Rate Widget for Symfony

I'm happy to contribute with symfony community posting my first plugin that provide a widget for rating system with stars.

The widget use a jQuery Javascript library that creates a non-obstrusive star rating control based on a set of radio input boxes. The script used for javascript is http://www.fyneworks.com/jquery/star-rating/

URL from Trac: http://www.symfony-project.org/plugins/mpStarRatingPlugin

Syndicate content