location || !file_exists (dirname ($this->location)) && !is_writable (dirname ($this->location))) return false; return true; } function load ($data) { $mine = array ('location', 'canonical', 'strip_index', 'memory_limit', 'error_level', 'ban_ip', 'allow_ip', 'raw', 'site'); foreach ($mine AS $key) { if (isset ($data[$key])) $this->$key = $data[$key]; } } function module_flush_delete () { @unlink ($this->location); } function module_flush ($items) { // Produce the .htaccess file include_once (dirname (__FILE__).'/../models/htaccess.php'); $htaccess = new Red_Htaccess ($this); if (is_array ($items) && count ($items) > 0) { foreach ($items AS $item) $htaccess->add ($item); } $htaccess->save ($this->location, $this->name); } function save ($data) { $save = array ( 'location' => isset( $data['location'] ) ? $data['location'] : false, 'canonical' => isset( $data['canonical'] ) ? $data['canonical'] : false, 'strip_index' => isset( $data['strip_index'] ) ? $data['strip_index'] : false, 'memory_limit' => isset( $data['memory_limit'] ) ? $data['memory_limit'] : false, 'error_level' => isset( $data['error_level'] ) ? $data['error_level'] : false, 'ban_ip' => isset( $data['ban_ip'] ) ? $data['ban_ip'] : false, 'allow_ip' => isset( $data['allow_ip'] ) ? $data['allow_ip'] : false, 'raw' => isset( $data['raw'] ) ? $data['raw'] : false, 'site' => preg_replace ('@https?://@', '', $data['site']) ); $this->load ($save); return $save; } function config () { ?> : location == '') : ?>
%s', 'redirection'), ABSPATH); ?> :
: : : : : : : '; if ($this->location) { if (!file_exists (dirname ($this->location))) { echo ''.$this->location.'

'; echo __ ('Location is invalid - check that path exists', 'redirection'); return; } else if ((file_exists ($this->location) && !is_writable ($this->location)) || (!file_exists ($this->location) && !is_writable (dirname ($this->location)))) { echo ''.$this->location.'

'; echo __ ('Could not write to configured .htaccess file - check file permissions', 'redirection'); return; } else echo ''.$this->location.''; } else echo __ ('Disabled: enter the location of an .htaccess file for this to be valid', 'redirection'); echo '

'; $options = array (); if ($this->canonical != 'default' && !empty ($this->canonical)) $options[] = ($this->canonical == 'nowww') ? __ ('strip WWW', 'redirection') : __ ('force WWW', 'redirection'); if ($this->strip_index != 'default' && !empty ($this->strip_index)) $options[] = __ ('strip index', 'redirection'); if ($this->memory_limit > 0 && !empty ($this->memory_limit)) $options[] = sprintf (__ ('memory limit at %dMB', 'redirection'), $this->memory_limit); if ($this->error_level != 'default' && !empty ($this->error_level)) $options[] = ($this->error_level == 'none') ? __ ('no errors', 'redirection') : __ ('show errors', 'redirection'); if (!empty ($this->ban_ip)) $options[] = __ ('IPs are banned', 'redirection'); if (!empty ($this->allow_ip)) $options[] = __ ('IPs are allowed', 'redirection'); echo ''.ucfirst (implode (', ', $options)).''; } public function get_type_string() { return __( 'Apache', 'redirection' ); } }