# Copyright (C) 2006-2008, 2010 Karl O. Pinc
#
#    This file is part of Babase.
#
#    Babase is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Babase.  If not, see <http://www.gnu.org/licenses/>.
#
# Site specific php config directives for BABASE programs.

<Directory /var/www/html>
  # PHP settings
  php_value date.timezone America/New_York
  php_flag short_open_tag Off

  # Force https
  RewriteEngine on

#  # Allow crawlers to get robots.txt so they stop killing us. -rnh, 04/28/2010
#  RewriteCond   %{REQUEST_URI} ^/robots.txt$
#  RewriteRule  .*  - [L]
#
#  # The docs don't have to be via https
#  RewriteCond   %{REQUEST_URI} ^/babase_system(\.(html)|(txt)|(xml)$)|/ [OR]
#  RewriteCond   %{REQUEST_URI} ^/pocket_reference.pdf$ [OR]
#  RewriteCond   %{REQUEST_URI} ^/diagrams/
#  RewriteRule   .* - [L]
#
#  # Force all other access to be via https.
#  RewriteCond   %{HTTPS} !=on
#  RewriteRule   .* - [F]

  RewriteCond   %{HTTPS} !=on
  RewriteCond   %{REQUEST_URI} ^/programs/ [OR]
  RewriteCond   %{REQUEST_URI} ^/phpPgAdmin/
  RewriteRule   .* - [F]

  # Redirect the home page to the wiki.
  RedirectMatch permanent ^\/$ http://papio.biology.duke.edu/babasewiki

  # Redirect the wiki login page to https
  RewriteCond   %{HTTPS} !=on
  RewriteCond   %{REQUEST_URI} ^/babasewiki/UserPreferences$
  RewriteRule   .* https://papio.biology.duke.edu/babasewiki/UserPreferences [L]


  # Send anybody without access, notably, anybody who did not use
  # a https:// URL when required, to the home page.
  ErrorDocument 403 https://papio.biology.duke.edu/

  # Allow READMEs to show up.
  IndexIgnore .??* *~ *# HEADER* RCS CVS *,v *,t

  # File size upload stuff
  # (May as well set it globally for the site.)
  #php_value upload_max_filesize 100M
  #php_value post_max_size 200M
  php_value upload_max_filesize 5000M
  php_value post_max_size 10000M

</Directory>

<Directory /var/www/html/babase_system_html/>
  # The docs can be access without using https.
  RewriteEngine off
</Directory>

<Directory /var/www/html/diagrams/>
  # The docs can be access without using https.
  RewriteEngine off
</Directory>

<Directory /var/www/html/programs>
  # PHP settings
  php_flag short_open_tag Off
  php_value include_path .:/var/www/include
  # PHP session stuff
  php_value session.name babase
  php_value session.cookie_lifetime 3600
  php_flag session.use_only_cookies On
  php_value session.cookie_path /programs

  # File size upload stuff
  php_value upload_max_filesize 100M
  php_value post_max_size 200M
  # Gotta have memory to manipulate the uploaded file.
  php_value memory_limit "128M"

  # Force https
  RewriteEngine on
  RewriteCond   %{HTTPS} !=on
  RewriteRule   .* - [F]
</Directory>

<Directory /var/www/html/testing/programs>
  # PHP settings
  php_flag short_open_tag Off
  php_value include_path .:/var/www/html/testing/include
  # PHP session stuff
  php_value session.name babase
  php_value session.cookie_lifetime 3600
  php_flag session.use_only_cookies On
  php_value session.cookie_path /testing/programs

  # File size upload stuff
  # Pick up the root directory defaults.
  #php_value upload_max_filesize 100M
  #php_value post_max_size 200M

  # Force https
  RewriteEngine on
  RewriteCond   %{HTTPS} !=on
  RewriteRule   .* - [F]
</Directory>

<Directory /var/www/html/src>
  # The src can be access without using https.
  RewriteEngine off
  # Turn off php
  AddHandler default-handler .php
  Options Indexes FollowSymlinks
</Directory>

<Directory /var/www/html/repos>
  # The repositories can be accessed without using https.
  RewriteEngine off
  # Turn off php
  AddHandler default-handler .php
  Options Indexes
</Directory>
