Centos 安装tengine

http://tengine.taobao.org/

安装pcre和openssl

yum install pcre-devel
yum -y install openssl openssl-devel
wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
tar -zxvf tengine-2.1.0.tar.gz
cd tengine-2.1.0.
./configure
make
sudo make install

ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx

Drupal date pop-up 只能选择今天以后的日期

function MYMODULE_date_popup_process_alter(&$element, &$form_state, &$context) {
  if (isset($element['#field']['field_name'])) {
    switch($element['#field']['field_name']) {
      case 'field_material_group_play_date':
        $element['#datepicker_options'] = array(
            'minDate' => "+0",
        );
        $element['date'] = date_popup_process_date_part($element);
        break;
    }
  }
}

PHP 判断上传文件的mime类型

Drupal默认的上传我也不知道是不是属于bug. 当你只允许上传.jpg的图片时。如果我将一个.php的文件后缀改成.jpg也能够正常上传。以下我写了一个修复脚本

/**
 * Implements hook_file_validate
 */
function mymodulename_file_validate($file) {
  $errors = array();
  $mime = mime_content_type(drupal_realpath($file->uri));
  if($mime != $file->filemime) {
    $errors[] = t('Upload error, the file format is not valid.');
  }
  return $errors;
}