diff --git a/application/config/mimes.php b/application/config/mimes.php
index 100f7d4..0ec9db0 100644
--- a/application/config/mimes.php
+++ b/application/config/mimes.php
@@ -1,4 +1,6 @@
- 'application/mac-binhex40',
- 'cpt' => 'application/mac-compactpro',
- 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
- 'bin' => 'application/macbinary',
- 'dms' => 'application/octet-stream',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'exe' => array('application/octet-stream', 'application/x-msdownload'),
- 'class' => 'application/octet-stream',
- 'psd' => 'application/x-photoshop',
- 'so' => 'application/octet-stream',
- 'sea' => 'application/octet-stream',
- 'dll' => 'application/octet-stream',
- 'oda' => 'application/oda',
- 'pdf' => array('application/pdf', 'application/x-download'),
- 'ai' => 'application/postscript',
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'mif' => 'application/vnd.mif',
- 'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
- 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
- 'wbxml' => 'application/wbxml',
- 'wmlc' => 'application/wmlc',
- 'dcr' => 'application/x-director',
- 'dir' => 'application/x-director',
- 'dxr' => 'application/x-director',
- 'dvi' => 'application/x-dvi',
- 'gtar' => 'application/x-gtar',
- 'gz' => 'application/x-gzip',
- 'php' => 'application/x-httpd-php',
- 'php4' => 'application/x-httpd-php',
- 'php3' => 'application/x-httpd-php',
- 'phtml' => 'application/x-httpd-php',
- 'phps' => 'application/x-httpd-php-source',
- 'js' => 'application/x-javascript',
- 'swf' => 'application/x-shockwave-flash',
- 'sit' => 'application/x-stuffit',
- 'tar' => 'application/x-tar',
- 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
- 'xhtml' => 'application/xhtml+xml',
- 'xht' => 'application/xhtml+xml',
- 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mpga' => 'audio/mpeg',
- 'mp2' => 'audio/mpeg',
- 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
- 'aif' => 'audio/x-aiff',
- 'aiff' => 'audio/x-aiff',
- 'aifc' => 'audio/x-aiff',
- 'ram' => 'audio/x-pn-realaudio',
- 'rm' => 'audio/x-pn-realaudio',
- 'rpm' => 'audio/x-pn-realaudio-plugin',
- 'ra' => 'audio/x-realaudio',
- 'rv' => 'video/vnd.rn-realvideo',
- 'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
- 'bmp' => array('image/bmp', 'image/x-windows-bmp'),
- 'gif' => 'image/gif',
- 'jpeg' => array('image/jpeg', 'image/pjpeg'),
- 'jpg' => array('image/jpeg', 'image/pjpeg'),
- 'jpe' => array('image/jpeg', 'image/pjpeg'),
- 'png' => array('image/png', 'image/x-png'),
- 'tiff' => 'image/tiff',
- 'tif' => 'image/tiff',
- 'css' => 'text/css',
- 'html' => 'text/html',
- 'htm' => 'text/html',
- 'shtml' => 'text/html',
- 'txt' => 'text/plain',
- 'text' => 'text/plain',
- 'log' => array('text/plain', 'text/x-log'),
- 'rtx' => 'text/richtext',
- 'rtf' => 'text/rtf',
- 'xml' => 'text/xml',
- 'xsl' => 'text/xml',
- 'mpeg' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mpe' => 'video/mpeg',
- 'qt' => 'video/quicktime',
- 'mov' => 'video/quicktime',
- 'avi' => 'video/x-msvideo',
- 'movie' => 'video/x-sgi-movie',
- 'doc' => 'application/msword',
- 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'),
- 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip'),
- 'word' => array('application/msword', 'application/octet-stream'),
- 'xl' => 'application/excel',
- 'eml' => 'message/rfc822',
- 'json' => array('application/json', 'text/json')
- );
-
-
-/* End of file mimes.php */
-/* Location: ./application/config/mimes.php */
+return array(
+ 'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
+ 'cpt' => 'application/mac-compactpro',
+ 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
+ 'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
+ 'dms' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'exe' => array('application/octet-stream', 'application/x-msdownload'),
+ 'class' => 'application/octet-stream',
+ 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
+ 'so' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
+ 'ai' => array('application/pdf', 'application/postscript'),
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
+ 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
+ 'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
+ 'wbxml' => 'application/wbxml',
+ 'wmlc' => 'application/wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'gz' => 'application/x-gzip',
+ 'gzip' => 'application/x-gzip',
+ 'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
+ 'php4' => 'application/x-httpd-php',
+ 'php3' => 'application/x-httpd-php',
+ 'phtml' => 'application/x-httpd-php',
+ 'phps' => 'application/x-httpd-php-source',
+ 'js' => array('application/x-javascript', 'text/plain'),
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
+ 'z' => 'application/x-compress',
+ 'xhtml' => 'application/xhtml+xml',
+ 'xht' => 'application/xhtml+xml',
+ 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
+ 'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mpga' => 'audio/mpeg',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
+ 'aif' => array('audio/x-aiff', 'audio/aiff'),
+ 'aiff' => array('audio/x-aiff', 'audio/aiff'),
+ 'aifc' => 'audio/x-aiff',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'rm' => 'audio/x-pn-realaudio',
+ 'rpm' => 'audio/x-pn-realaudio-plugin',
+ 'ra' => 'audio/x-realaudio',
+ 'rv' => 'video/vnd.rn-realvideo',
+ 'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
+ 'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
+ 'gif' => 'image/gif',
+ 'jpeg' => array('image/jpeg', 'image/pjpeg'),
+ 'jpg' => array('image/jpeg', 'image/pjpeg'),
+ 'jpe' => array('image/jpeg', 'image/pjpeg'),
+ 'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
+ 'png' => array('image/png', 'image/x-png'),
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'css' => array('text/css', 'text/plain'),
+ 'html' => array('text/html', 'text/plain'),
+ 'htm' => array('text/html', 'text/plain'),
+ 'shtml' => array('text/html', 'text/plain'),
+ 'txt' => 'text/plain',
+ 'text' => 'text/plain',
+ 'log' => array('text/plain', 'text/x-log'),
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'xml' => array('application/xml', 'text/xml', 'text/plain'),
+ 'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'qt' => 'video/quicktime',
+ 'mov' => 'video/quicktime',
+ 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
+ 'movie' => 'video/x-sgi-movie',
+ 'doc' => array('application/msword', 'application/vnd.ms-office'),
+ 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
+ 'dot' => array('application/msword', 'application/vnd.ms-office'),
+ 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
+ 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
+ 'word' => array('application/msword', 'application/octet-stream'),
+ 'xl' => 'application/excel',
+ 'eml' => 'message/rfc822',
+ 'json' => array('application/json', 'text/json'),
+ 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
+ 'p10' => array('application/x-pkcs10', 'application/pkcs10'),
+ 'p12' => 'application/x-pkcs12',
+ 'p7a' => 'application/x-pkcs7-signature',
+ 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
+ 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
+ 'p7r' => 'application/x-pkcs7-certreqresp',
+ 'p7s' => 'application/pkcs7-signature',
+ 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
+ 'crl' => array('application/pkix-crl', 'application/pkcs-crl'),
+ 'der' => 'application/x-x509-ca-cert',
+ 'kdb' => 'application/octet-stream',
+ 'pgp' => 'application/pgp',
+ 'gpg' => 'application/gpg-keys',
+ 'sst' => 'application/octet-stream',
+ 'csr' => 'application/octet-stream',
+ 'rsa' => 'application/x-pkcs7',
+ 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
+ '3g2' => 'video/3gpp2',
+ '3gp' => array('video/3gp', 'video/3gpp'),
+ 'mp4' => 'video/mp4',
+ 'm4a' => 'audio/x-m4a',
+ 'f4v' => array('video/mp4', 'video/x-f4v'),
+ 'flv' => 'video/x-flv',
+ 'webm' => 'video/webm',
+ 'aac' => 'audio/x-acc',
+ 'm4u' => 'application/vnd.mpegurl',
+ 'm3u' => 'text/plain',
+ 'xspf' => 'application/xspf+xml',
+ 'vlc' => 'application/videolan',
+ 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
+ 'au' => 'audio/x-au',
+ 'ac3' => 'audio/ac3',
+ 'flac' => 'audio/x-flac',
+ 'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'),
+ 'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
+ 'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
+ 'ics' => 'text/calendar',
+ 'ical' => 'text/calendar',
+ 'zsh' => 'text/x-scriptzsh',
+ '7z' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
+ '7zip' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
+ 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
+ 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
+ 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
+ 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
+ 'vcf' => 'text/x-vcard',
+ 'srt' => array('text/srt', 'text/plain'),
+ 'vtt' => array('text/vtt', 'text/plain'),
+ 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
+ 'odc' => 'application/vnd.oasis.opendocument.chart',
+ 'otc' => 'application/vnd.oasis.opendocument.chart-template',
+ 'odf' => 'application/vnd.oasis.opendocument.formula',
+ 'otf' => 'application/vnd.oasis.opendocument.formula-template',
+ 'odg' => 'application/vnd.oasis.opendocument.graphics',
+ 'otg' => 'application/vnd.oasis.opendocument.graphics-template',
+ 'odi' => 'application/vnd.oasis.opendocument.image',
+ 'oti' => 'application/vnd.oasis.opendocument.image-template',
+ 'odp' => 'application/vnd.oasis.opendocument.presentation',
+ 'otp' => 'application/vnd.oasis.opendocument.presentation-template',
+ 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+ 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'odt' => 'application/vnd.oasis.opendocument.text',
+ 'odm' => 'application/vnd.oasis.opendocument.text-master',
+ 'ott' => 'application/vnd.oasis.opendocument.text-template',
+ 'oth' => 'application/vnd.oasis.opendocument.text-web'
+);
diff --git a/application/controllers/admin.php b/application/controllers/admin.php
index 685bd6e..6ed3e77 100644
--- a/application/controllers/admin.php
+++ b/application/controllers/admin.php
@@ -13,7 +13,7 @@ class Admin extends CI_Controller {
**/
//$this->template->load(template, view, vars)
- function Admin(){
+ function __construct(){
parent::__construct();
//Check for existing login
@@ -36,7 +36,7 @@ function Admin(){
//If site constant is set to debug, enable the profiler (gives analytics for page load).
//DO NOT USE ON LIVE SITE
- if($this->input->get('debug') !== false) $this->output->enable_profiler(DEBUG_MODE);
+ if($this->input->get('debug') !== NULL) $this->output->enable_profiler(DEBUG_MODE);
}
@@ -433,7 +433,7 @@ function rooms(){
$requires_moderation = $this->input->post('requires_moderation');
//If no resources are selected, create an empty array
- if($resources === false) $resources = array();
+ if($resources === NULL) $resources = array();
$id = $this->room_model->edit_room($room_id, $building, $room, $seats, $roles, $active, $resources, $max_daily_hours, $notes, $requires_moderation);
@@ -810,7 +810,7 @@ function block_booking(){
$rooms = $this->input->post('rooms');
$permissions = $this->input->post('permissions');
- if($permissions === false) $permissions = array();
+ if($permissions === NULL) $permissions = array();
$status = $this->booking_model->add_block_booking($reason,$start,$end, $rooms, $permissions);
@@ -870,7 +870,7 @@ function block_booking(){
$id = $this->input->post('block_booking_id');
$permissions = $this->input->post('permissions');
- if($permissions === false) $permissions = array();
+ if($permissions === NULL) $permissions = array();
$status = $this->booking_model->edit_block_booking($reason,$start,$end, $rooms, $permissions, $id);
@@ -914,7 +914,7 @@ function recurring_booking(){
$permissions = $this->input->post('permissions');
$repeat_interval = $this->input->post('repeat_interval');
- if($permissions === false) $permissions = array();
+ if($permissions === NULL) $permissions = array();
$status = $this->booking_model->add_recurring_booking($reason, $start, $end, $start_time, $end_time, $rooms, $permissions, $repeat_interval);
@@ -976,7 +976,7 @@ function recurring_booking(){
$repeat_interval = $this->input->post('repeat_interval');
$id = $this->input->post('block_booking_id');
- if($permissions === false) $permissions = array();
+ if($permissions === NULL) $permissions = array();
$status = $this->booking_model->edit_recurring_booking($reason, $start, $end, $start_time, $end_time, $rooms, $permissions, $repeat_interval, $id);
@@ -1036,7 +1036,7 @@ function moderate(){
$this->load->model('booking_model');
if($this->uri->segment(3) === 'approve'){
- if($this->uri->segment(4) !== FALSE && is_numeric($this->uri->segment(4))){
+ if($this->uri->segment(4) !== NULL && is_numeric($this->uri->segment(4))){
$ret_val = $this->booking_model->moderator_approve($this->uri->segment(4));
if($ret_val === FALSE){
@@ -1081,7 +1081,7 @@ function moderate(){
}
else if($this->uri->segment(3) === 'deny'){
- if($this->uri->segment(4) !== FALSE && is_numeric($this->uri->segment(4))){
+ if($this->uri->segment(4) !== NULL && is_numeric($this->uri->segment(4))){
//Save the data first, in order to be able to populate the email
$mod_data = $this->booking_model->load_moderation_entry($this->uri->segment(4))->row();
@@ -1148,21 +1148,21 @@ function reports(){
$data['roles'] = $this->role_model->list_roles();
//Refine by buildings
- if($this->input->get('building') !== FALSE && is_numeric($this->input->get('building'))){
+ if($this->input->get('building') !== NULL && is_numeric($this->input->get('building'))){
$building_id = $this->input->get('building');
}
else{
$building_id = null;
}
- if($this->input->get('room') !== FALSE && is_numeric($this->input->get('room'))){
+ if($this->input->get('room') !== NULL && is_numeric($this->input->get('room'))){
$room_id = $this->input->get('room');
}
else{
$room_id = null;
}
- if($this->input->get('role') !== FALSE && is_numeric($this->input->get('role'))){
+ if($this->input->get('role') !== NULL && is_numeric($this->input->get('role'))){
$role_id = $this->input->get('role');
}
else{
@@ -1171,7 +1171,7 @@ function reports(){
//Refine by start/end times
- if($this->input->get('start_date') !== FALSE && strlen($this->input->get('start_date')) > 0 && $this->input->get('end_date') !== FALSE && strlen($this->input->get('end_date')) > 0){
+ if($this->input->get('start_date') !== NULL && strlen($this->input->get('start_date')) > 0 && $this->input->get('end_date') !== NULL && strlen($this->input->get('end_date')) > 0){
$start_time = strtotime($this->input->get('start_date'));
$end_time = strtotime($this->input->get('end_date'))+ ((24*60*60)-1); //Add a day (minus a second) to get as late as possible
}
@@ -1226,12 +1226,12 @@ function error_logs(){
$this->load->model('log_model');
if($this->uri->segment(3) === "delete"){
- if($this->uri->segment(4) !== false){
+ if($this->uri->segment(4) !== NULL){
$this->log_model->delete_log($this->uri->segment(4));
}
redirect('admin/error_logs');
}
- elseif($this->uri->segment(3) !== false){
+ elseif($this->uri->segment(3) !== NULL){
$data['log_data'] = $this->log_model->get_log($this->uri->segment(3));
}
else{
@@ -1254,7 +1254,7 @@ function check_for_bookings(){
$data['rooms'] = $this->room_model->list_rooms();
- if($this->input->post('username') !== FALSE){
+ if($this->input->post('username') !== NULL){
$data['upcoming_user_bookings'] = $this->booking_model->get_upcoming_bookings($this->input->post('username'));
$data['current_user_bookings'] = $this->booking_model->get_current_bookings($this->input->post('username'));
$data['past_user_bookings'] = $this->booking_model->get_previous_bookings($this->input->post('username'), 100);
@@ -1262,7 +1262,7 @@ function check_for_bookings(){
$data['username_mode'] = TRUE;
}
- else if($this->input->post('fullname') !== FALSE){
+ else if($this->input->post('fullname') !== NULL){
if(strlen($this->input->post('fullname')) > 3){ //Prevent massive lists of results
$data['fullname_bookings'] = $this->booking_model->get_bookings_by_name($this->input->post('fullname'));
$data['searched'] = $this->input->post('fullname');
@@ -1270,8 +1270,8 @@ function check_for_bookings(){
}
}
- else if($this->input->post('room') !== FALSE){
- $this->load->library('calendar');
+ else if($this->input->post('room') !== NULL){
+ $this->load->library('bookingcalendar');
$start = $this->input->post('start');
$end = $this->input->post('end');
@@ -1279,10 +1279,10 @@ function check_for_bookings(){
if(is_array($this->input->post('room'))){
//If Dates aren't valid or set, default to 'today'
- if($start === FALSE || !$this->calendar->isValidDateTimeString($start, 'Y-m-d')){
+ if($start === NULL || !$this->bookingcalendar->isValidDateTimeString($start, 'Y-m-d')){
$start = date('Y-m-d');
}
- if($end === FALSE || !$this->calendar->isValidDateTimeString($end, 'Y-m-d')){
+ if($end === NULL || !$this->bookingcalendar->isValidDateTimeString($end, 'Y-m-d')){
$end = date('Y-m-d');
}
if(strtotime($start) > strtotime($end)){
diff --git a/application/controllers/api.php b/application/controllers/api.php
index a3787fa..2ba053b 100644
--- a/application/controllers/api.php
+++ b/application/controllers/api.php
@@ -13,10 +13,10 @@ class Api extends CI_Controller {
**/
- function Api(){
+ function __construct(){
parent::__construct();
- if($this->input->get('debug') !== false) $this->output->enable_profiler(DEBUG_MODE);
+ if($this->input->get('debug') !== NULL) $this->output->enable_profiler(DEBUG_MODE);
}
@@ -35,7 +35,7 @@ function room_data(){
$requested_room = $this->uri->segment(3);
- if($requested_room === FALSE){
+ if($requested_room === NULL){
echo '[]';
return;
}
diff --git a/application/controllers/booking.php b/application/controllers/booking.php
index 894b677..26e1031 100644
--- a/application/controllers/booking.php
+++ b/application/controllers/booking.php
@@ -13,7 +13,7 @@ class Booking extends CI_Controller {
**/
//$this->template->load(template, view, vars)
- function Booking(){
+ function __construct(){
parent::__construct();
$this->load->library('cas');
@@ -41,14 +41,14 @@ function Booking(){
//If site constant is set to debug, enable the profiler (gives analytics for page load).
//DO NOT USE ON LIVE SITE
- if($this->input->get('debug') !== false) $this->output->enable_profiler(DEBUG_MODE);
+ if($this->input->get('debug') !== NULL) $this->output->enable_profiler(DEBUG_MODE);
//$this->output->enable_profiler(DEBUG_MODE);
}
public function booking_main(){
//Default to today if no date is selected
- if($this->input->get('month') === FALSE && $this->input->get('date') === FALSE){
+ if($this->input->get('month') === NULL && $this->input->get('date') === NULL){
//Keep flashdata if redirecting to "today"
foreach($this->session->all_userdata() as $key => $val){
@@ -66,7 +66,7 @@ public function booking_main(){
$this->load->model('booking_model');
$this->load->model('resource_model');
$this->load->model('hours_model');
- $this->load->library('calendar');
+ $this->load->library('bookingCalendar');
//Get the theme to load assets
$data['theme'] = str_replace("_template", "", $this->role_model->get_theme());
@@ -91,19 +91,21 @@ public function booking_main(){
}
//Generate the calendar needed
- if($this->input->get('month') !== false){
- if($this->input->get('date') !== false){
+ if($this->input->get('month') !== NULL){
+ if($this->input->get('date') !== NULL){
//Return all bookings for the day (as an associative array for easy retrieval)
$bookings = $this->booking_model->get_bookings($this->input->get('date', TRUE));
- foreach($bookings->result() as $booking){
- $data['bookings'][$booking->room_id][strtotime($booking->start)] = $booking;
+ if($bookings !== FALSE){
+ foreach($bookings->result() as $booking){
+ $data['bookings'][$booking->room_id][strtotime($booking->start)] = $booking;
+ }
}
$current_month = date_parse_from_format('Ymd', $this->input->get('date', TRUE));
- $data['calendar'] = $this->calendar->drawCalendar( $current_month['month'], $current_month['year'], $current_month['day']);
+ $data['calendar'] = $this->bookingcalendar->drawCalendar( $current_month['month'], $current_month['year'], $current_month['day']);
//Load the hours for the selected date
$data['hours'] = $this->hours_model->getAllHours(mktime(0,0,0, $current_month['month'],$current_month['day'],$current_month['year']));
@@ -117,11 +119,11 @@ public function booking_main(){
}
else{
$current_month = date_parse_from_format('Ym', $this->input->get('month', TRUE));
- $data['calendar'] = $this->calendar->drawCalendar( $current_month['month'], $current_month['year'] );
+ $data['calendar'] = $this->bookingcalendar->drawCalendar( $current_month['month'], $current_month['year'] );
}
}
else{
- $data['calendar'] = $this->calendar->drawCalendar();
+ $data['calendar'] = $this->bookingcalendar->drawCalendar();
}
@@ -169,7 +171,7 @@ function book_room(){
redirect(base_url());
}
- if($this->input->get('slot') === FALSE || !is_numeric($this->input->get('slot')) || $this->input->get('room_id') === FALSE || !is_numeric($this->input->get('room_id'))){
+ if($this->input->get('slot') === NULL || !is_numeric($this->input->get('slot')) || $this->input->get('room_id') === NULL || !is_numeric($this->input->get('room_id'))){
//Bad data, do something
}
else{
@@ -245,10 +247,10 @@ function submit(){
}
else{
//Try to make the booking
-
- //Is this booking an edit?
- if($this->input->post('booking_id') !== FALSE && is_numeric($this->input->post('booking_id'))){
+ //Is this booking an edit?
+ if($this->input->post('booking_id') !== NULL && is_numeric($this->input->post('booking_id'))){
+
//Check if user was allowed to make this booking
$data['booking'] = $this->booking_model->get_booking($this->input->post('booking_id'));
@@ -400,17 +402,18 @@ function edit_booking(){
$this->load->model('booking_model');
$this->load->model('interface_model');
-
- if($this->input->get('booking_id') === FALSE || !is_numeric($this->input->get('booking_id'))){
+
+ if($this->input->get('booking_id') === NULL || !is_numeric($this->input->get('booking_id'))){
+
$this->session->set_flashdata('warning', "An error has occured. ");
redirect(base_url().'booking/booking_main');
}
$booking_data = $this->booking_model->get_booking($this->input->get('booking_id'));
- if($booking_data->num_rows == 0){
+ if($booking_data->num_rows() == 0){
$this->session->set_flashdata('warning', "An error has occured.");
redirect(base_url().'booking/booking_main');
}
@@ -498,7 +501,7 @@ function delete_booking(){
$booking_data = $this->booking_model->get_booking($this->input->get('booking_id'));
$data['booking'] = $booking_data->row();
- if($data['booking'] === FALSE || $booking_data->num_rows == 0){
+ if($data['booking'] === FALSE || $booking_data->num_rows() == 0){
$this->session->set_flashdata('warning', "An error has occured. The booking has not been deleted");
redirect(base_url().'booking/booking_main');
}
diff --git a/application/controllers/login.php b/application/controllers/login.php
index f5b08ff..7811fea 100644
--- a/application/controllers/login.php
+++ b/application/controllers/login.php
@@ -13,7 +13,7 @@ class Login extends CI_Controller {
**/
//$this->template->load(template, view, vars)
- function Login(){
+ function __construct(){
parent::__construct();
//If site constant is set to debug, enable the profiler (gives analytics for page load).
diff --git a/application/controllers/mobile.php b/application/controllers/mobile.php
index ba4bca3..2a3242d 100644
--- a/application/controllers/mobile.php
+++ b/application/controllers/mobile.php
@@ -13,7 +13,7 @@ class Mobile extends CI_Controller {
**/
//$this->template->load(template, view, vars)
- function Mobile(){
+ function __construct(){
parent::__construct();
$this->load->library('cas');
@@ -34,7 +34,7 @@ function Mobile(){
//If site constant is set to debug, enable the profiler (gives analytics for page load).
//DO NOT USE ON LIVE SITE
- if($this->input->get('debug') !== false) $this->output->enable_profiler(DEBUG_MODE);
+ if($this->input->get('debug') !== NULL) $this->output->enable_profiler(DEBUG_MODE);
}
@@ -113,13 +113,13 @@ function book_room(){
$data['roles'] = $this->role_model->list_roles();
- if($this->input->get('selected_date') !== FALSE && strtotime($this->input->get('selected_date')) !== FALSE){
+ if($this->input->get('selected_date') !== NULL && strtotime($this->input->get('selected_date')) !== NULL){
$data['hours'] = $this->hours_model->getAllHours(strtotime($this->input->get('selected_date')));
}
- if($this->input->get('selected_date') !== FALSE && $this->input->get('set_time') !== FALSE){
+ if($this->input->get('selected_date') !== NULL && $this->input->get('set_time') !== NULL){
$data['limits'] = $this->booking_model->remaining_hours($this->session->userdata('username'), $this->input->get('set_time'));
@@ -178,14 +178,14 @@ function edit_booking(){
$this->load->model('interface_model');
- if($this->input->get('booking_id') === FALSE || !is_numeric($this->input->get('booking_id'))){
+ if($this->input->get('booking_id') === NULL || !is_numeric($this->input->get('booking_id'))){
$this->session->set_flashdata('warning', "An error has occured. ");
redirect(base_url().'mobile');
}
$booking_data = $this->booking_model->get_booking($this->input->get('booking_id'));
- if($booking_data->num_rows == 0){
+ if($booking_data->num_rows() == 0){
$this->session->set_flashdata('warning', "An error has occured.");
redirect(base_url().'mobile');
}
@@ -381,7 +381,7 @@ function cancel_booking(){
$booking_data = $this->booking_model->get_booking($this->input->get('booking_id'));
$data['booking'] = $booking_data->row();
- if($data['booking'] === FALSE || $booking_data->num_rows == 0){
+ if($data['booking'] === FALSE || $booking_data->num_rows() == 0){
$this->session->set_flashdata('warning', "An error has occured. The booking has not been deleted");
redirect(base_url() . 'mobile');
}
diff --git a/application/core/MY_Input.php b/application/core/MY_Input.php
deleted file mode 100644
index 5737357..0000000
--- a/application/core/MY_Input.php
+++ /dev/null
@@ -1,25 +0,0 @@
-uni->clean_string($str);
- }
-
- return $str;
- }
-}
\ No newline at end of file
diff --git a/application/libraries/Calendar.php b/application/libraries/Bookingcalendar.php
similarity index 99%
rename from application/libraries/Calendar.php
rename to application/libraries/Bookingcalendar.php
index 7e20418..10ff1f4 100644
--- a/application/libraries/Calendar.php
+++ b/application/libraries/Bookingcalendar.php
@@ -1,6 +1,6 @@
'', 'port' => 443);
$cas_url = array_merge($defaults, parse_url($this->cas_server_url));
- phpCAS::client(SAML_VERSION_1_1, $cas_url['host'],
- $cas_url['port'], $cas_url['path']);
+
+
+ if(isset($_SESSION))
+ phpCAS::client(SAML_VERSION_1_1, $cas_url['host'], $cas_url['port'], $cas_url['path'], false); //use existing session
+ else
+ phpCAS::client(SAML_VERSION_1_1, $cas_url['host'],$cas_url['port'], $cas_url['path']); //let phpCAS manage the session
+
// configures SSL behavior
if ($CI->config->item('cas_disable_server_validation')){
diff --git a/application/models/booking_model.php b/application/models/booking_model.php
index 887bd18..abced8e 100644
--- a/application/models/booking_model.php
+++ b/application/models/booking_model.php
@@ -665,11 +665,11 @@ function get_block_booking($id){
}
function add_block_booking($reason, $start, $end, $rooms, $permissions){
- $this->load->library('calendar');
+ $this->load->library('bookingcalendar');
//Check for valid input formats
if(!is_array($rooms)) return FALSE;
- if(!$this->calendar->isValidDateTimeString($start, 'Y-m-d G:i') || !$this->calendar->isValidDateTimeString($end, 'Y-m-d G:i'))return FALSE;
+ if(!$this->bookingcalendar->isValidDateTimeString($start, 'Y-m-d G:i') || !$this->bookingcalendar->isValidDateTimeString($end, 'Y-m-d G:i'))return FALSE;
//Make sure the end is always after the start
$dt_start = date_create($start);
@@ -700,12 +700,12 @@ function add_block_booking($reason, $start, $end, $rooms, $permissions){
}
function add_recurring_booking($reason, $start, $end, $start_time, $end_time, $rooms, $permissions, $repeat_interval){
- $this->load->library('calendar');
+ $this->load->library('bookingcalendar');
//Check for valid input formats
if(!is_array($rooms)) return FALSE;
if(!is_numeric($repeat_interval)) return FALSE;
- if(!$this->calendar->isValidDateTimeString($start, 'Y-m-d') || !$this->calendar->isValidDateTimeString($end, 'Y-m-d')) return FALSE;
+ if(!$this->bookingcalendar->isValidDateTimeString($start, 'Y-m-d') || !$this->bookingcalendar->isValidDateTimeString($end, 'Y-m-d')) return FALSE;
//Make sure the end is always after the start
$dt_start = date_create($start);
@@ -744,11 +744,11 @@ function add_recurring_booking($reason, $start, $end, $start_time, $end_time, $r
}
function edit_block_booking($reason, $start, $end, $rooms, $permissions, $id){
- $this->load->library('calendar');
+ $this->load->library('bookingcalendar');
if(!is_array($rooms)) return FALSE;
- if(!$this->calendar->isValidDateTimeString($start, 'Y-m-d G:i') || !$this->calendar->isValidDateTimeString($end, 'Y-m-d G:i'))return FALSE;
+ if(!$this->bookingcalendar->isValidDateTimeString($start, 'Y-m-d G:i') || !$this->bookingcalendar->isValidDateTimeString($end, 'Y-m-d G:i'))return FALSE;
//Make sure the end is always after the start
$dt_start = date_create($start);
$dt_end = date_create($end);
@@ -784,11 +784,11 @@ function edit_block_booking($reason, $start, $end, $rooms, $permissions, $id){
function edit_recurring_booking($reason, $start, $end, $start_time, $end_time, $rooms, $permissions, $repeat_interval, $id){
- $this->load->library('calendar');
+ $this->load->library('bookingcalendar');
if(!is_array($rooms)) return FALSE;
- if(!$this->calendar->isValidDateTimeString($start, 'Y-m-d') || !$this->calendar->isValidDateTimeString($end, 'Y-m-d'))return FALSE;
+ if(!$this->bookingcalendar->isValidDateTimeString($start, 'Y-m-d') || !$this->bookingcalendar->isValidDateTimeString($end, 'Y-m-d'))return FALSE;
//Make sure the end is always after the start
$dt_start = date_create($start);
$dt_end = date_create($end);
diff --git a/application/models/building_model.php b/application/models/building_model.php
index a0d6600..e7c8912 100644
--- a/application/models/building_model.php
+++ b/application/models/building_model.php
@@ -22,7 +22,7 @@ function load_building($building_id){
$this->db->where('building_id', $building_id);
$data['building_data'] = $this->db->get('buildings');
- if($data['building_data']->num_rows > 0){
+ if($data['building_data']->num_rows() > 0){
return $data;
}
else{
diff --git a/application/models/hours_model.php b/application/models/hours_model.php
index a5b21e2..02c58e4 100644
--- a/application/models/hours_model.php
+++ b/application/models/hours_model.php
@@ -154,7 +154,7 @@ function getAllHours($date){
//Convert the external ID into the building id
else{
$building = $this->building_model->get_by_external_id($location->LOCATION_ID);
- if($building->num_rows === 0) continue;
+ if($building->num_rows() === 0) continue;
else $building_id = $building->row()->building_id;
}
@@ -208,10 +208,10 @@ function get_closure($building_id, $date){
}
function add_closure($building_id, $date){
- $this->load->library('calendar');
+ $this->load->library('bookingcalendar');
//Validate the date string
- if(!$this->calendar->isValidDateTimeString($date, 'Y-m-d')) return FALSE;
+ if(!$this->bookingcalendar->isValidDateTimeString($date, 'Y-m-d')) return FALSE;
$data = array(
'building_id' => $building_id,
@@ -251,14 +251,14 @@ function get_hours($building_id, $include_past = false){
}
function add_hours($building_id, $start_date, $end_date, $hours_data){
- $this->load->library('calendar');
+ $this->load->library('bookingcalendar');
//Validate all the inputs
if(!is_numeric($building_id)) return 'Invalid Building ID';
//Start/End dates are formatted correctly
- if(!$this->calendar->isValidDateTimeString($start_date, 'Y-m-d')) return 'Invalid Start Date';
- if(!$this->calendar->isValidDateTimeString($end_date, 'Y-m-d')) return 'Invalid End Date';
+ if(!$this->bookingcalendar->isValidDateTimeString($start_date, 'Y-m-d')) return 'Invalid Start Date';
+ if(!$this->bookingcalendar->isValidDateTimeString($end_date, 'Y-m-d')) return 'Invalid End Date';
//Make sure an entry doesn't already exist with conflicting dates
$other_hours = $this->get_hours($building_id, true);
@@ -279,7 +279,7 @@ function add_hours($building_id, $start_date, $end_date, $hours_data){
//All times are formatted correctly
foreach($hours_data as $entry){
- if($entry !== "24:00" && !$this->calendar->isValidDateTimeString($entry, 'H:i')) return 'Time format of '.$entry.' is not valid';
+ if($entry !== "24:00" && !$this->bookingcalendar->isValidDateTimeString($entry, 'H:i')) return 'Time format of '.$entry.' is not valid';
}
//Make sure the start time is not later then the end time
diff --git a/application/models/room_model.php b/application/models/room_model.php
index 095a02a..127e67b 100644
--- a/application/models/room_model.php
+++ b/application/models/room_model.php
@@ -105,7 +105,7 @@ function load_room_by_name($name){
$data['room_data'] = $this->db->get('rooms',1);
//Get the room_id
- if($data['room_data']->num_rows > 0){
+ if($data['room_data']->num_rows() > 0){
$temp_result = $data['room_data']->row();
$id = $temp_result->room_id;
}
diff --git a/application/views/admin/check_for_bookings.php b/application/views/admin/check_for_bookings.php
index b6d0469..e0cb4f4 100644
--- a/application/views/admin/check_for_bookings.php
+++ b/application/views/admin/check_for_bookings.php
@@ -10,7 +10,7 @@
input->get('start_date') !== FALSE && strlen($this->input->get('start_date')) > 0 && $this->input->get('end_date') !== FALSE && strlen($this->input->get('end_date')) > 0){
+ if($this->input->get('start_date') !== NULL && strlen($this->input->get('start_date')) > 0 && $this->input->get('end_date') !== NULL && strlen($this->input->get('end_date')) > 0){
$date_str = date('F j, Y', strtotime($this->input->get('start_date'))) . " - ". date('F j, Y', strtotime($this->input->get('end_date')));
}
else{
diff --git a/application/views/admin/reports.php b/application/views/admin/reports.php
index 5236a5f..2a070e9 100644
--- a/application/views/admin/reports.php
+++ b/application/views/admin/reports.php
@@ -39,7 +39,7 @@
input->get('start_date') !== FALSE && strlen($this->input->get('start_date')) > 0 && $this->input->get('end_date') !== FALSE && strlen($this->input->get('end_date')) > 0){
+ if($this->input->get('start_date') !== NULL && strlen($this->input->get('start_date')) > 0 && $this->input->get('end_date') !== NULL && strlen($this->input->get('end_date')) > 0){
$date_str = date('F j, Y', strtotime($this->input->get('start_date'))) . " - ". date('F j, Y', strtotime($this->input->get('end_date')));
}
else{
@@ -54,13 +54,13 @@
diff --git a/application/views/booking/book_room_form.php b/application/views/booking/book_room_form.php
index eb3d57b..121bd4c 100644
--- a/application/views/booking/book_room_form.php
+++ b/application/views/booking/book_room_form.php
@@ -23,7 +23,7 @@
input->get('slot') === FALSE || !is_numeric($this->input->get('slot')) || $this->input->get('room_id') === FALSE || !is_numeric($this->input->get('room_id')) || ($this->input->get('slot') % 1800) !== 0): ?>
+if($this->input->get('slot') === NULL || !is_numeric($this->input->get('slot')) || $this->input->get('room_id') === NULL || !is_numeric($this->input->get('room_id')) || ($this->input->get('slot') % 1800) !== 0): ?>
An Error has occurred.
row(); ?>
@@ -70,7 +70,7 @@
$end_time = $start_time + (($room_data->max_daily_hours - $limits['day_used'])*60*60 );
//If there is another booking ahead of this, do not allow for overlap
- if($next_booking->num_rows > 0 && $next_booking->row()->start != null && $end_time > strtotime($next_booking->row()->start)){
+ if($next_booking->num_rows() > 0 && $next_booking->row()->start != null && $end_time > strtotime($next_booking->row()->start)){
$end_time = strtotime($next_booking->row()->start);
diff --git a/application/views/booking/booking_main.php b/application/views/booking/booking_main.php
index 4c873a7..f821d54 100644
--- a/application/views/booking/booking_main.php
+++ b/application/views/booking/booking_main.php
@@ -26,10 +26,10 @@
-session->flashdata('notice') !== FALSE): ?>session->flashdata('notice'); ?>
-session->flashdata('warning') !== FALSE): ?>session->flashdata('warning'); ?>
-session->flashdata('success') !== FALSE): ?>session->flashdata('success'); ?>
-session->flashdata('danger') !== FALSE): ?>session->flashdata('danger'); ?>
+session->flashdata('notice') !== NULL): ?>session->flashdata('notice'); ?>
+session->flashdata('warning') !== NULL): ?>session->flashdata('warning'); ?>
+session->flashdata('success') !== NULL): ?>session->flashdata('success'); ?>
+session->flashdata('danger') !== NULL): ?>session->flashdata('danger'); ?>
-input->get('date') !== FALSE): ?>
+input->get('date') !== NULL): ?>
diff --git a/application/views/booking/edit_book_room_form.php b/application/views/booking/edit_book_room_form.php
index 9addc02..41634b1 100644
--- a/application/views/booking/edit_book_room_form.php
+++ b/application/views/booking/edit_book_room_form.php
@@ -24,7 +24,7 @@
input->get('booking_id') === FALSE || !is_numeric($this->input->get('booking_id'))): ?>
+if($this->input->get('booking_id') === NULL || !is_numeric($this->input->get('booking_id'))): ?>
An Error has occurred.
row(); ?>
@@ -111,7 +111,7 @@
//If there is another booking ahead of this, do not allow for overlap
- if($next_booking->num_rows > 0 && $next_booking->row()->start != null && $end_time > strtotime($next_booking->row()->start)){
+ if($next_booking->num_rows() > 0 && $next_booking->row()->start != null && $end_time > strtotime($next_booking->row()->start)){
$end_time = strtotime($next_booking->row()->start);
@@ -294,14 +294,14 @@
diff --git a/application/views/booking/my_bookings.php b/application/views/booking/my_bookings.php
index 80fca1f..791c5f0 100644
--- a/application/views/booking/my_bookings.php
+++ b/application/views/booking/my_bookings.php
@@ -21,10 +21,10 @@
-session->flashdata('notice') !== FALSE): ?>session->flashdata('notice'); ?>
-session->flashdata('warning') !== FALSE): ?>session->flashdata('warning'); ?>
-session->flashdata('success') !== FALSE): ?>session->flashdata('success'); ?>
-session->flashdata('danger') !== FALSE): ?>session->flashdata('danger'); ?>
+session->flashdata('notice') !== NULL): ?>session->flashdata('notice'); ?>
+session->flashdata('warning') !== NULL): ?>session->flashdata('warning'); ?>
+session->flashdata('success') !== NULL): ?>session->flashdata('success'); ?>
+session->flashdata('danger') !== NULL): ?>session->flashdata('danger'); ?>
@@ -69,7 +69,7 @@
- num_rows > 0): ?>
+ num_rows() > 0): ?>
Current Bookings
@@ -96,7 +96,7 @@
Upcoming Bookings
- num_rows > 0): ?>
+ num_rows() > 0): ?>
@@ -136,7 +136,7 @@
Previous Bookings
- num_rows > 0): ?>
+ num_rows() > 0): ?>
diff --git a/application/views/errors/cli/error_404.php b/application/views/errors/cli/error_404.php
new file mode 100644
index 0000000..6984b61
--- /dev/null
+++ b/application/views/errors/cli/error_404.php
@@ -0,0 +1,8 @@
+
+
+An uncaught Exception was encountered
+
+Type:
+Message:
+Filename: getFile(), "\n"; ?>
+Line Number: getLine(); ?>
+
+
+
+Backtrace:
+getTrace() as $error): ?>
+
+ File:
+ Line:
+ Function:
+
+
+
+
diff --git a/application/views/errors/cli/error_general.php b/application/views/errors/cli/error_general.php
new file mode 100644
index 0000000..6984b61
--- /dev/null
+++ b/application/views/errors/cli/error_general.php
@@ -0,0 +1,8 @@
+
+
+A PHP Error was encountered
+
+Severity:
+Message:
+Filename:
+Line Number:
+
+
+
+Backtrace:
+
+
+ File:
+ Line:
+ Function:
+
+
+
+
diff --git a/application/views/errors/cli/index.html b/application/views/errors/cli/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/application/views/errors/cli/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/application/views/errors/html/error_404.php b/application/views/errors/html/error_404.php
new file mode 100644
index 0000000..756ea9d
--- /dev/null
+++ b/application/views/errors/html/error_404.php
@@ -0,0 +1,64 @@
+
+
+
+
+404 Page Not Found
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/html/error_db.php b/application/views/errors/html/error_db.php
new file mode 100644
index 0000000..f5a43f6
--- /dev/null
+++ b/application/views/errors/html/error_db.php
@@ -0,0 +1,64 @@
+
+
+
+
+Database Error
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/html/error_exception.php b/application/views/errors/html/error_exception.php
new file mode 100644
index 0000000..8784886
--- /dev/null
+++ b/application/views/errors/html/error_exception.php
@@ -0,0 +1,32 @@
+
+
+
+
+
An uncaught Exception was encountered
+
+
Type:
+
Message:
+
Filename: getFile(); ?>
+
Line Number: getLine(); ?>
+
+
+
+
Backtrace:
+ getTrace() as $error): ?>
+
+
+
+
+ File:
+ Line:
+ Function:
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/html/error_general.php b/application/views/errors/html/error_general.php
new file mode 100644
index 0000000..fc3b2eb
--- /dev/null
+++ b/application/views/errors/html/error_general.php
@@ -0,0 +1,64 @@
+
+
+
+
+Error
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/html/error_php.php b/application/views/errors/html/error_php.php
new file mode 100644
index 0000000..b146f9c
--- /dev/null
+++ b/application/views/errors/html/error_php.php
@@ -0,0 +1,33 @@
+
+
+
+
+
A PHP Error was encountered
+
+
Severity:
+
Message:
+
Filename:
+
Line Number:
+
+
+
+
Backtrace:
+
+
+
+
+
+ File:
+ Line:
+ Function:
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/views/errors/html/index.html b/application/views/errors/html/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/application/views/errors/html/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/application/views/errors/index.html b/application/views/errors/index.html
new file mode 100644
index 0000000..b702fbc
--- /dev/null
+++ b/application/views/errors/index.html
@@ -0,0 +1,11 @@
+
+
+
+ 403 Forbidden
+
+
+
+Directory access is forbidden.
+
+
+
diff --git a/application/views/fcs_template.php b/application/views/fcs_template.php
index d30ae6b..a763f92 100644
--- a/application/views/fcs_template.php
+++ b/application/views/fcs_template.php
@@ -9,12 +9,15 @@
Room Booking - Faculty of Community Services - Ryerson University
+
-
+
+
+
diff --git a/application/views/mobile/book_room.php b/application/views/mobile/book_room.php
index 2d0448e..3a04d51 100644
--- a/application/views/mobile/book_room.php
+++ b/application/views/mobile/book_room.php
@@ -12,13 +12,13 @@
- session->flashdata('notice') !== FALSE): ?>session->flashdata('notice')); ?>
- session->flashdata('warning') !== FALSE): ?>session->flashdata('warning')); ?>
- session->flashdata('success') !== FALSE): ?>session->flashdata('success')); ?>
- session->flashdata('danger') !== FALSE): ?>session->flashdata('danger')); ?>
+ session->flashdata('notice') !== NULL): ?>session->flashdata('notice')); ?>
+ session->flashdata('warning') !== NULL): ?>session->flashdata('warning')); ?>
+ session->flashdata('success') !== NULL): ?>session->flashdata('success')); ?>
+ session->flashdata('danger') !== NULL): ?>session->flashdata('danger')); ?>
- input->get('selected_date') !== FALSE && $this->input->get('set_time') !== FALSE): ?>
+ input->get('selected_date') !== NULL && $this->input->get('set_time') !== NULL): ?>
input->get('set_time') > time()): ?>
@@ -230,7 +230,7 @@
- input->get('selected_date') === FALSE): ?>
+ input->get('selected_date') === NULL): ?>
';
- }
- else
- {
- return $r;
- }
+ return ($inline)
+ ? ''
+ : $r;
}
}
// ------------------------------------------------------------------------
-/**
- * Get Clickable Smileys
- *
- * Returns an array of image tag links that can be clicked to be inserted
- * into a form field.
- *
- * @access public
- * @param string the URL to the folder containing the smiley images
- * @return array
- */
if ( ! function_exists('get_clickable_smileys'))
{
- function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
+ /**
+ * Get Clickable Smileys
+ *
+ * Returns an array of image tag links that can be clicked to be inserted
+ * into a form field.
+ *
+ * @param string the URL to the folder containing the smiley images
+ * @param array
+ * @return array
+ */
+ function get_clickable_smileys($image_url, $alias = '')
{
// For backward compatibility with js_insert_smiley
-
if (is_array($alias))
{
$smileys = $alias;
}
-
- if ( ! is_array($smileys))
+ elseif (FALSE === ($smileys = _get_smiley_array()))
{
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $smileys;
- }
+ return FALSE;
}
// Add a trailing slash to the file path if needed
@@ -158,7 +165,7 @@ function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
foreach ($smileys as $key => $val)
{
// Keep duplicates from being used, which can happen if the
- // mapping array contains multiple identical replacements. For example:
+ // mapping array contains multiple identical replacements. For example:
// :-) and :) might be replaced with the same image so both smileys
// will be in the array.
if (isset($used[$smileys[$key][0]]))
@@ -166,8 +173,7 @@ function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
continue;
}
- $link[] = " ";
-
+ $link[] = ' ';
$used[$smileys[$key][0]] = TRUE;
}
@@ -177,39 +183,31 @@ function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
// ------------------------------------------------------------------------
-/**
- * Parse Smileys
- *
- * Takes a string as input and swaps any contained smileys for the actual image
- *
- * @access public
- * @param string the text to be parsed
- * @param string the URL to the folder containing the smiley images
- * @return string
- */
if ( ! function_exists('parse_smileys'))
{
+ /**
+ * Parse Smileys
+ *
+ * Takes a string as input and swaps any contained smileys for the actual image
+ *
+ * @param string the text to be parsed
+ * @param string the URL to the folder containing the smiley images
+ * @param array
+ * @return string
+ */
function parse_smileys($str = '', $image_url = '', $smileys = NULL)
{
- if ($image_url == '')
+ if ($image_url === '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array())))
{
return $str;
}
- if ( ! is_array($smileys))
- {
- if (FALSE === ($smileys = _get_smiley_array()))
- {
- return $str;
- }
- }
-
// Add a trailing slash to the file path if needed
- $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url);
+ $image_url = rtrim($image_url, '/').'/';
foreach ($smileys as $key => $val)
{
- $str = str_replace($key, " ", $str);
+ $str = str_replace($key, ' ', $str);
}
return $str;
@@ -218,65 +216,40 @@ function parse_smileys($str = '', $image_url = '', $smileys = NULL)
// ------------------------------------------------------------------------
-/**
- * Get Smiley Array
- *
- * Fetches the config/smiley.php file
- *
- * @access private
- * @return mixed
- */
if ( ! function_exists('_get_smiley_array'))
{
+ /**
+ * Get Smiley Array
+ *
+ * Fetches the config/smiley.php file
+ *
+ * @return mixed
+ */
function _get_smiley_array()
{
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
- }
- elseif (file_exists(APPPATH.'config/smileys.php'))
- {
- include(APPPATH.'config/smileys.php');
- }
-
- if (isset($smileys) AND is_array($smileys))
+ static $_smileys;
+
+ if ( ! is_array($_smileys))
{
- return $smileys;
- }
+ if (file_exists(APPPATH.'config/smileys.php'))
+ {
+ include(APPPATH.'config/smileys.php');
+ }
- return FALSE;
- }
-}
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
+ }
-// ------------------------------------------------------------------------
+ if (empty($smileys) OR ! is_array($smileys))
+ {
+ $_smileys = array();
+ return FALSE;
+ }
-/**
- * JS Insert Smiley
- *
- * Generates the javascript function needed to insert smileys into a form field
- *
- * DEPRECATED as of version 1.7.2, use smiley_js instead
- *
- * @access public
- * @param string form name
- * @param string field name
- * @return string
- */
-if ( ! function_exists('js_insert_smiley'))
-{
- function js_insert_smiley($form_name = '', $form_field = '')
- {
- return <<
- function insert_smiley(smiley)
- {
- document.{$form_name}.{$form_field}.value += " " + smiley;
- }
-
-EOF;
+ $_smileys = $smileys;
+ }
+
+ return $_smileys;
}
}
-
-
-/* End of file smiley_helper.php */
-/* Location: ./system/helpers/smiley_helper.php */
\ No newline at end of file
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index aeeba99..c7dd969 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -1,20 +1,41 @@
- $val)
- {
- $str[$key] = strip_slashes($val);
- }
+ return stripslashes($str);
}
- else
+
+ foreach ($str as $key => $val)
{
- $str = stripslashes($str);
+ $str[$key] = strip_slashes($val);
}
return $str;
@@ -84,17 +104,16 @@ function strip_slashes($str)
// ------------------------------------------------------------------------
-/**
- * Strip Quotes
- *
- * Removes single and double quotes from a string
- *
- * @access public
- * @param string
- * @return string
- */
if ( ! function_exists('strip_quotes'))
{
+ /**
+ * Strip Quotes
+ *
+ * Removes single and double quotes from a string
+ *
+ * @param string
+ * @return string
+ */
function strip_quotes($str)
{
return str_replace(array('"', "'"), '', $str);
@@ -103,17 +122,16 @@ function strip_quotes($str)
// ------------------------------------------------------------------------
-/**
- * Quotes to Entities
- *
- * Converts single and double quotes to entities
- *
- * @access public
- * @param string
- * @return string
- */
if ( ! function_exists('quotes_to_entities'))
{
+ /**
+ * Quotes to Entities
+ *
+ * Converts single and double quotes to entities
+ *
+ * @param string
+ * @return string
+ */
function quotes_to_entities($str)
{
return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str);
@@ -122,164 +140,144 @@ function quotes_to_entities($str)
// ------------------------------------------------------------------------
-/**
- * Reduce Double Slashes
- *
- * Converts double slashes in a string to a single slash,
- * except those found in http://
- *
- * http://www.some-site.com//index.php
- *
- * becomes:
- *
- * http://www.some-site.com/index.php
- *
- * @access public
- * @param string
- * @return string
- */
if ( ! function_exists('reduce_double_slashes'))
{
+ /**
+ * Reduce Double Slashes
+ *
+ * Converts double slashes in a string to a single slash,
+ * except those found in http://
+ *
+ * http://www.some-site.com//index.php
+ *
+ * becomes:
+ *
+ * http://www.some-site.com/index.php
+ *
+ * @param string
+ * @return string
+ */
function reduce_double_slashes($str)
{
- return preg_replace("#(^|[^:])//+#", "\\1/", $str);
+ return preg_replace('#(^|[^:])//+#', '\\1/', $str);
}
}
// ------------------------------------------------------------------------
-/**
- * Reduce Multiples
- *
- * Reduces multiple instances of a particular character. Example:
- *
- * Fred, Bill,, Joe, Jimmy
- *
- * becomes:
- *
- * Fred, Bill, Joe, Jimmy
- *
- * @access public
- * @param string
- * @param string the character you wish to reduce
- * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
- * @return string
- */
if ( ! function_exists('reduce_multiples'))
{
+ /**
+ * Reduce Multiples
+ *
+ * Reduces multiple instances of a particular character. Example:
+ *
+ * Fred, Bill,, Joe, Jimmy
+ *
+ * becomes:
+ *
+ * Fred, Bill, Joe, Jimmy
+ *
+ * @param string
+ * @param string the character you wish to reduce
+ * @param bool TRUE/FALSE - whether to trim the character from the beginning/end
+ * @return string
+ */
function reduce_multiples($str, $character = ',', $trim = FALSE)
{
$str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str);
-
- if ($trim === TRUE)
- {
- $str = trim($str, $character);
- }
-
- return $str;
+ return ($trim === TRUE) ? trim($str, $character) : $str;
}
}
// ------------------------------------------------------------------------
-/**
- * Create a Random String
- *
- * Useful for generating passwords or hashes.
- *
- * @access public
- * @param string type of random string. basic, alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
- * @param integer number of characters
- * @return string
- */
if ( ! function_exists('random_string'))
{
+ /**
+ * Create a "Random" String
+ *
+ * @param string type of random string. basic, alpha, alnum, numeric, nozero, unique, md5, encrypt and sha1
+ * @param int number of characters
+ * @return string
+ */
function random_string($type = 'alnum', $len = 8)
{
- switch($type)
+ switch ($type)
{
- case 'basic' : return mt_rand();
- break;
- case 'alnum' :
- case 'numeric' :
- case 'nozero' :
- case 'alpha' :
-
- switch ($type)
- {
- case 'alpha' : $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- break;
- case 'alnum' : $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- break;
- case 'numeric' : $pool = '0123456789';
- break;
- case 'nozero' : $pool = '123456789';
- break;
- }
-
- $str = '';
- for ($i=0; $i < $len; $i++)
- {
- $str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
- }
- return $str;
- break;
- case 'unique' :
- case 'md5' :
-
- return md5(uniqid(mt_rand()));
- break;
- case 'encrypt' :
- case 'sha1' :
-
- $CI =& get_instance();
- $CI->load->helper('security');
-
- return do_hash(uniqid(mt_rand(), TRUE), 'sha1');
- break;
+ case 'basic':
+ return mt_rand();
+ case 'alnum':
+ case 'numeric':
+ case 'nozero':
+ case 'alpha':
+ switch ($type)
+ {
+ case 'alpha':
+ $pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ break;
+ case 'alnum':
+ $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ break;
+ case 'numeric':
+ $pool = '0123456789';
+ break;
+ case 'nozero':
+ $pool = '123456789';
+ break;
+ }
+ return substr(str_shuffle(str_repeat($pool, ceil($len / strlen($pool)))), 0, $len);
+ case 'unique': // todo: remove in 3.1+
+ case 'md5':
+ return md5(uniqid(mt_rand()));
+ case 'encrypt': // todo: remove in 3.1+
+ case 'sha1':
+ return sha1(uniqid(mt_rand(), TRUE));
}
}
}
// ------------------------------------------------------------------------
-/**
- * Add's _1 to a string or increment the ending number to allow _2, _3, etc
- *
- * @param string $str required
- * @param string $separator What should the duplicate number be appended with
- * @param string $first Which number should be used for the first dupe increment
- * @return string
- */
-function increment_string($str, $separator = '_', $first = 1)
+if ( ! function_exists('increment_string'))
{
- preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
-
- return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ /**
+ * Add's _1 to a string or increment the ending number to allow _2, _3, etc
+ *
+ * @param string required
+ * @param string What should the duplicate number be appended with
+ * @param string Which number should be used for the first dupe increment
+ * @return string
+ */
+ function increment_string($str, $separator = '_', $first = 1)
+ {
+ preg_match('/(.+)'.preg_quote($separator, '/').'([0-9]+)$/', $str, $match);
+ return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+ }
}
// ------------------------------------------------------------------------
-/**
- * Alternator
- *
- * Allows strings to be alternated. See docs...
- *
- * @access public
- * @param string (as many parameters as needed)
- * @return string
- */
if ( ! function_exists('alternator'))
{
+ /**
+ * Alternator
+ *
+ * Allows strings to be alternated. See docs...
+ *
+ * @param string (as many parameters as needed)
+ * @return string
+ */
function alternator()
{
static $i;
- if (func_num_args() == 0)
+ if (func_num_args() === 0)
{
$i = 0;
return '';
}
+
$args = func_get_args();
return $args[($i++ % count($args))];
}
@@ -287,22 +285,20 @@ function alternator()
// ------------------------------------------------------------------------
-/**
- * Repeater function
- *
- * @access public
- * @param string
- * @param integer number of repeats
- * @return string
- */
if ( ! function_exists('repeater'))
{
+ /**
+ * Repeater function
+ *
+ * @todo Remove in version 3.1+.
+ * @deprecated 3.0.0 This is just an alias for PHP's native str_repeat()
+ *
+ * @param string $data String to repeat
+ * @param int $num Number of repeats
+ * @return string
+ */
function repeater($data, $num = 1)
{
- return (($num > 0) ? str_repeat($data, $num) : '');
+ return ($num > 0) ? str_repeat($data, $num) : '';
}
}
-
-
-/* End of file string_helper.php */
-/* Location: ./system/helpers/string_helper.php */
\ No newline at end of file
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 85c3091..e1c5e24 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -1,20 +1,41 @@
-= $n)
+ if (mb_strlen($out) >= $n)
{
$out = trim($out);
- return (strlen($out) == strlen($str)) ? $out : $out.$end_char;
+ return (mb_strlen($out) === mb_strlen($str)) ? $out : $out.$end_char;
}
}
}
@@ -105,24 +125,23 @@ function character_limiter($str, $n = 500, $end_char = '…')
// ------------------------------------------------------------------------
-/**
- * High ASCII to Entities
- *
- * Converts High ascii text and MS Word special characters to character entities
- *
- * @access public
- * @param string
- * @return string
- */
if ( ! function_exists('ascii_to_entities'))
{
+ /**
+ * High ASCII to Entities
+ *
+ * Converts high ASCII text and MS Word special characters to character entities
+ *
+ * @param string $str
+ * @return string
+ */
function ascii_to_entities($str)
{
- $count = 1;
- $out = '';
- $temp = array();
-
- for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ $out = '';
+ $length = defined('MB_OVERLOAD_STRING')
+ ? mb_strlen($str, '8bit') - 1
+ : strlen($str) - 1;
+ for ($i = 0, $count = 1, $temp = array(); $i <= $length; $i++)
{
$ordinal = ord($str[$i]);
@@ -132,9 +151,9 @@ function ascii_to_entities($str)
If the $temp array has a value but we have moved on, then it seems only
fair that we output that entity and restart $temp before continuing. -Paul
*/
- if (count($temp) == 1)
+ if (count($temp) === 1)
{
- $out .= ''.array_shift($temp).';';
+ $out .= ''.array_shift($temp).';';
$count = 1;
}
@@ -142,21 +161,28 @@ function ascii_to_entities($str)
}
else
{
- if (count($temp) == 0)
+ if (count($temp) === 0)
{
$count = ($ordinal < 224) ? 2 : 3;
}
$temp[] = $ordinal;
- if (count($temp) == $count)
+ if (count($temp) === $count)
{
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+ $number = ($count === 3)
+ ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64)
+ : (($temp[0] % 32) * 64) + ($temp[1] % 64);
$out .= ''.$number.';';
$count = 1;
$temp = array();
}
+ // If this is the last iteration, just output whatever we have
+ elseif ($i === $length)
+ {
+ $out .= ''.implode(';', $temp).';';
+ }
}
}
@@ -166,26 +192,24 @@ function ascii_to_entities($str)
// ------------------------------------------------------------------------
-/**
- * Entities to ASCII
- *
- * Converts character entities back to ASCII
- *
- * @access public
- * @param string
- * @param bool
- * @return string
- */
if ( ! function_exists('entities_to_ascii'))
{
+ /**
+ * Entities to ASCII
+ *
+ * Converts character entities back to ASCII
+ *
+ * @param string
+ * @param bool
+ * @return string
+ */
function entities_to_ascii($str, $all = TRUE)
{
if (preg_match_all('/\(\d+)\;/', $str, $matches))
{
- for ($i = 0, $s = count($matches['0']); $i < $s; $i++)
+ for ($i = 0, $s = count($matches[0]); $i < $s; $i++)
{
- $digits = $matches['1'][$i];
-
+ $digits = $matches[1][$i];
$out = '';
if ($digits < 128)
@@ -195,25 +219,26 @@ function entities_to_ascii($str, $all = TRUE)
}
elseif ($digits < 2048)
{
- $out .= chr(192 + (($digits - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
+ $out .= chr(192 + (($digits - ($digits % 64)) / 64)).chr(128 + ($digits % 64));
}
else
{
- $out .= chr(224 + (($digits - ($digits % 4096)) / 4096));
- $out .= chr(128 + ((($digits % 4096) - ($digits % 64)) / 64));
- $out .= chr(128 + ($digits % 64));
+ $out .= chr(224 + (($digits - ($digits % 4096)) / 4096))
+ .chr(128 + ((($digits % 4096) - ($digits % 64)) / 64))
+ .chr(128 + ($digits % 64));
}
- $str = str_replace($matches['0'][$i], $out, $str);
+ $str = str_replace($matches[0][$i], $out, $str);
}
}
if ($all)
{
- $str = str_replace(array("&", "<", ">", """, "'", "-"),
- array("&","<",">","\"", "'", "-"),
- $str);
+ return str_replace(
+ array('&', '<', '>', '"', ''', '-'),
+ array('&', '<', '>', '"', "'", '-'),
+ $str
+ );
}
return $str;
@@ -222,21 +247,20 @@ function entities_to_ascii($str, $all = TRUE)
// ------------------------------------------------------------------------
-/**
- * Word Censoring Function
- *
- * Supply a string and an array of disallowed words and any
- * matched words will be converted to #### or to the replacement
- * word you've submitted.
- *
- * @access public
- * @param string the text string
- * @param string the array of censoered words
- * @param string the optional replacement value
- * @return string
- */
if ( ! function_exists('word_censor'))
{
+ /**
+ * Word Censoring Function
+ *
+ * Supply a string and an array of disallowed words and any
+ * matched words will be converted to #### or to the replacement
+ * word you've submitted.
+ *
+ * @param string the text string
+ * @param string the array of censored words
+ * @param string the optional replacement value
+ * @return string
+ */
function word_censor($str, $censored, $replacement = '')
{
if ( ! is_array($censored))
@@ -254,13 +278,28 @@ function word_censor($str, $censored, $replacement = '')
foreach ($censored as $badword)
{
- if ($replacement != '')
+ $badword = str_replace('\*', '\w*?', preg_quote($badword, '/'));
+ if ($replacement !== '')
{
- $str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/i", "\\1{$replacement}\\3", $str);
+ $str = preg_replace(
+ "/({$delim})(".$badword.")({$delim})/i",
+ "\\1{$replacement}\\3",
+ $str
+ );
}
- else
+ elseif (preg_match_all("/{$delim}(".$badword."){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE))
{
- $str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/ie", "'\\1'.str_repeat('#', strlen('\\2')).'\\3'", $str);
+ $matches = $matches[1];
+ for ($i = count($matches) - 1; $i >= 0; $i--)
+ {
+ $length = strlen($matches[$i][0]);
+ $str = substr_replace(
+ $str,
+ str_repeat('#', $length),
+ $matches[$i][1],
+ $length
+ );
+ }
}
}
@@ -270,136 +309,146 @@ function word_censor($str, $censored, $replacement = '')
// ------------------------------------------------------------------------
-/**
- * Code Highlighter
- *
- * Colorizes code strings
- *
- * @access public
- * @param string the text string
- * @return string
- */
if ( ! function_exists('highlight_code'))
{
+ /**
+ * Code Highlighter
+ *
+ * Colorizes code strings
+ *
+ * @param string the text string
+ * @return string
+ */
function highlight_code($str)
{
- // The highlight string function encodes and highlights
- // brackets so we need them to start raw
- $str = str_replace(array('<', '>'), array('<', '>'), $str);
-
- // Replace any existing PHP tags to temporary markers so they don't accidentally
- // break the string out of PHP, and thus, thwart the highlighting.
-
- $str = str_replace(array('', '?>', '<%', '%>', '\\', ''),
- array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'), $str);
+ /* The highlight string function encodes and highlights
+ * brackets so we need them to start raw.
+ *
+ * Also replace any existing PHP tags to temporary markers
+ * so they don't accidentally break the string out of PHP,
+ * and thus, thwart the highlighting.
+ */
+ $str = str_replace(
+ array('<', '>', '', '?>', '<%', '%>', '\\', ''),
+ array('<', '>', 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ $str
+ );
// The highlight_string function requires that the text be surrounded
// by PHP tags, which we will remove later
- $str = ''; //
-
- // All the magic happens here, baby!
- $str = highlight_string($str, TRUE);
+ $str = highlight_string('', TRUE);
// Remove our artificially added PHP, and the syntax highlighting that came with it
- $str = preg_replace('/<\?php( | )/i', '', $str);
- $str = preg_replace('/(.*?)\?><\/span>\n<\/span>\n<\/code>/is', "$1 \n \n", $str);
- $str = preg_replace('/<\/span>/i', '', $str);
+ $str = preg_replace(
+ array(
+ '/<\?php( | )/i',
+ '/(.*?)\?><\/span>\n<\/span>\n<\/code>/is',
+ '/<\/span>/i'
+ ),
+ array(
+ '',
+ "$1 \n \n",
+ ''
+ ),
+ $str
+ );
// Replace our markers back to PHP tags.
- $str = str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
- array('<?', '?>', '<%', '%>', '\\', '</script>'), $str);
-
- return $str;
+ return str_replace(
+ array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+ array('<?', '?>', '<%', '%>', '\\', '</script>'),
+ $str
+ );
}
}
// ------------------------------------------------------------------------
-/**
- * Phrase Highlighter
- *
- * Highlights a phrase within a text string
- *
- * @access public
- * @param string the text string
- * @param string the phrase you'd like to highlight
- * @param string the openging tag to precede the phrase with
- * @param string the closing tag to end the phrase with
- * @return string
- */
if ( ! function_exists('highlight_phrase'))
{
- function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = ' ')
+ /**
+ * Phrase Highlighter
+ *
+ * Highlights a phrase within a text string
+ *
+ * @param string $str the text string
+ * @param string $phrase the phrase you'd like to highlight
+ * @param string $tag_open the openging tag to precede the phrase with
+ * @param string $tag_close the closing tag to end the phrase with
+ * @return string
+ */
+ function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = ' ')
{
- if ($str == '')
- {
- return '';
- }
-
- if ($phrase != '')
- {
- return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open."\\1".$tag_close, $str);
- }
-
- return $str;
+ return ($str !== '' && $phrase !== '')
+ ? preg_replace('/('.preg_quote($phrase, '/').')/i'.(UTF8_ENABLED ? 'u' : ''), $tag_open.'\\1'.$tag_close, $str)
+ : $str;
}
}
// ------------------------------------------------------------------------
-/**
- * Convert Accented Foreign Characters to ASCII
- *
- * @access public
- * @param string the text string
- * @return string
- */
if ( ! function_exists('convert_accented_characters'))
{
+ /**
+ * Convert Accented Foreign Characters to ASCII
+ *
+ * @param string $str Input string
+ * @return string
+ */
function convert_accented_characters($str)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
- }
- elseif (is_file(APPPATH.'config/foreign_chars.php'))
- {
- include(APPPATH.'config/foreign_chars.php');
- }
+ static $array_from, $array_to;
- if ( ! isset($foreign_characters))
+ if ( ! is_array($array_from))
{
- return $str;
+ if (file_exists(APPPATH.'config/foreign_chars.php'))
+ {
+ include(APPPATH.'config/foreign_chars.php');
+ }
+
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php');
+ }
+
+ if (empty($foreign_characters) OR ! is_array($foreign_characters))
+ {
+ $array_from = array();
+ $array_to = array();
+
+ return $str;
+ }
+
+ $array_from = array_keys($foreign_characters);
+ $array_to = array_values($foreign_characters);
}
- return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str);
+ return preg_replace($array_from, $array_to, $str);
}
}
// ------------------------------------------------------------------------
-/**
- * Word Wrap
- *
- * Wraps text at the specified character. Maintains the integrity of words.
- * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
- * will URLs.
- *
- * @access public
- * @param string the text string
- * @param integer the number of characters to wrap at
- * @return string
- */
if ( ! function_exists('word_wrap'))
{
- function word_wrap($str, $charlim = '76')
+ /**
+ * Word Wrap
+ *
+ * Wraps text at the specified character. Maintains the integrity of words.
+ * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor
+ * will URLs.
+ *
+ * @param string $str the text string
+ * @param int $charlim = 76 the number of characters to wrap at
+ * @return string
+ */
+ function word_wrap($str, $charlim = 76)
{
- // Se the character limit
- if ( ! is_numeric($charlim))
- $charlim = 76;
+ // Set the character limit
+ is_numeric($charlim) OR $charlim = 76;
// Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
+ $str = preg_replace('| +|', ' ', $str);
// Standardize newlines
if (strpos($str, "\r") !== FALSE)
@@ -410,58 +459,56 @@ function word_wrap($str, $charlim = '76')
// If the current word is surrounded by {unwrap} tags we'll
// strip the entire chunk and replace it with a marker.
$unwrap = array();
- if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
+ if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches))
{
- for ($i = 0; $i < count($matches['0']); $i++)
+ for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
{
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ $unwrap[] = $matches[1][$i];
+ $str = str_replace($matches[0][$i], '{{unwrapped'.$i.'}}', $str);
}
}
// Use PHP's native function to do the initial wordwrap.
// We set the cut flag to FALSE so that any individual words that are
- // too long get left alone. In the next step we'll deal with them.
+ // too long get left alone. In the next step we'll deal with them.
$str = wordwrap($str, $charlim, "\n", FALSE);
// Split the string into individual lines of text and cycle through them
- $output = "";
+ $output = '';
foreach (explode("\n", $str) as $line)
{
// Is the line within the allowed character count?
// If so we'll join it to the output and continue
- if (strlen($line) <= $charlim)
+ if (mb_strlen($line) <= $charlim)
{
$output .= $line."\n";
continue;
}
$temp = '';
- while ((strlen($line)) > $charlim)
+ while (mb_strlen($line) > $charlim)
{
// If the over-length word is a URL we won't wrap it
- if (preg_match("!\[url.+\]|://|wwww.!", $line))
+ if (preg_match('!\[url.+\]|://|www\.!', $line))
{
break;
}
// Trim the word down
- $temp .= substr($line, 0, $charlim-1);
- $line = substr($line, $charlim-1);
+ $temp .= mb_substr($line, 0, $charlim - 1);
+ $line = mb_substr($line, $charlim - 1);
}
// If $temp contains data it means we had to split up an over-length
// word into smaller chunks so we'll add it back to our current line
- if ($temp != '')
+ if ($temp !== '')
{
- $output .= $temp."\n".$line;
+ $output .= $temp."\n".$line."\n";
}
else
{
- $output .= $line;
+ $output .= $line."\n";
}
-
- $output .= "\n";
}
// Put our markers back
@@ -469,59 +516,52 @@ function word_wrap($str, $charlim = '76')
{
foreach ($unwrap as $key => $val)
{
- $output = str_replace("{{unwrapped".$key."}}", $val, $output);
+ $output = str_replace('{{unwrapped'.$key.'}}', $val, $output);
}
}
- // Remove the unwrap tags
- $output = str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
-
return $output;
}
}
// ------------------------------------------------------------------------
-/**
- * Ellipsize String
- *
- * This function will strip tags from a string, split it at its max_length and ellipsize
- *
- * @param string string to ellipsize
- * @param integer max length of string
- * @param mixed int (1|0) or float, .5, .2, etc for position to split
- * @param string ellipsis ; Default '...'
- * @return string ellipsized string
- */
if ( ! function_exists('ellipsize'))
{
+ /**
+ * Ellipsize String
+ *
+ * This function will strip tags from a string, split it at its max_length and ellipsize
+ *
+ * @param string string to ellipsize
+ * @param int max length of string
+ * @param mixed int (1|0) or float, .5, .2, etc for position to split
+ * @param string ellipsis ; Default '...'
+ * @return string ellipsized string
+ */
function ellipsize($str, $max_length, $position = 1, $ellipsis = '…')
{
// Strip tags
$str = trim(strip_tags($str));
// Is the string long enough to ellipsize?
- if (strlen($str) <= $max_length)
+ if (mb_strlen($str) <= $max_length)
{
return $str;
}
- $beg = substr($str, 0, floor($max_length * $position));
-
+ $beg = mb_substr($str, 0, floor($max_length * $position));
$position = ($position > 1) ? 1 : $position;
if ($position === 1)
{
- $end = substr($str, 0, -($max_length - strlen($beg)));
+ $end = mb_substr($str, 0, -($max_length - mb_strlen($beg)));
}
else
{
- $end = substr($str, -($max_length - strlen($beg)));
+ $end = mb_substr($str, -($max_length - mb_strlen($beg)));
}
return $beg.$ellipsis.$end;
}
}
-
-/* End of file text_helper.php */
-/* Location: ./system/helpers/text_helper.php */
\ No newline at end of file
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 1e7a6ab..d308a57 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -1,20 +1,41 @@
-load->library('typography');
-
return $CI->typography->nl2br_except_pre($str);
}
}
// ------------------------------------------------------------------------
-/**
- * Auto Typography Wrapper Function
- *
- *
- * @access public
- * @param string
- * @param bool whether to allow javascript event handlers
- * @param bool whether to reduce multiple instances of double newlines to two
- * @return string
- */
if ( ! function_exists('auto_typography'))
{
- function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE)
+ /**
+ * Auto Typography Wrapper Function
+ *
+ * @param string $str
+ * @param bool $reduce_linebreaks = FALSE whether to reduce multiple instances of double newlines to two
+ * @return string
+ */
+ function auto_typography($str, $reduce_linebreaks = FALSE)
{
$CI =& get_instance();
$CI->load->library('typography');
- return $CI->typography->auto_typography($str, $strip_js_event_handlers, $reduce_linebreaks);
+ return $CI->typography->auto_typography($str, $reduce_linebreaks);
}
}
-
// --------------------------------------------------------------------
-/**
- * HTML Entities Decode
- *
- * This function is a replacement for html_entity_decode()
- *
- * @access public
- * @param string
- * @return string
- */
if ( ! function_exists('entity_decode'))
{
- function entity_decode($str, $charset='UTF-8')
+ /**
+ * HTML Entities Decode
+ *
+ * This function is a replacement for html_entity_decode()
+ *
+ * @param string
+ * @param string
+ * @return string
+ */
+ function entity_decode($str, $charset = NULL)
{
- global $SEC;
- return $SEC->entity_decode($str, $charset);
+ return get_instance()->security->entity_decode($str, $charset);
}
}
-
-/* End of file typography_helper.php */
-/* Location: ./system/helpers/typography_helper.php */
\ No newline at end of file
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 4bdf067..bebfd25 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -1,20 +1,41 @@
-config->site_url($uri);
+ return get_instance()->config->site_url($uri, $protocol);
}
}
// ------------------------------------------------------------------------
-/**
- * Base URL
- *
- * Create a local URL based on your basepath.
- * Segments can be passed in as a string or an array, same as site_url
- * or a URL to a file can be passed in, e.g. to an image file.
- *
- * @access public
- * @param string
- * @return string
- */
if ( ! function_exists('base_url'))
{
- function base_url($uri = '')
+ /**
+ * Base URL
+ *
+ * Create a local URL based on your basepath.
+ * Segments can be passed in as a string or an array, same as site_url
+ * or a URL to a file can be passed in, e.g. to an image file.
+ *
+ * @param string $uri
+ * @param string $protocol
+ * @return string
+ */
+ function base_url($uri = '', $protocol = NULL)
{
- $CI =& get_instance();
- return $CI->config->base_url($uri);
+ return get_instance()->config->base_url($uri, $protocol);
}
}
// ------------------------------------------------------------------------
-/**
- * Current URL
- *
- * Returns the full URL (including segments) of the page where this
- * function is placed
- *
- * @access public
- * @return string
- */
if ( ! function_exists('current_url'))
{
+ /**
+ * Current URL
+ *
+ * Returns the full URL (including segments) of the page where this
+ * function is placed
+ *
+ * @return string
+ */
function current_url()
{
$CI =& get_instance();
@@ -90,78 +108,69 @@ function current_url()
}
// ------------------------------------------------------------------------
-/**
- * URL String
- *
- * Returns the URI segments.
- *
- * @access public
- * @return string
- */
+
if ( ! function_exists('uri_string'))
{
+ /**
+ * URL String
+ *
+ * Returns the URI segments.
+ *
+ * @return string
+ */
function uri_string()
{
- $CI =& get_instance();
- return $CI->uri->uri_string();
+ return get_instance()->uri->uri_string();
}
}
// ------------------------------------------------------------------------
-/**
- * Index page
- *
- * Returns the "index_page" from your config file
- *
- * @access public
- * @return string
- */
if ( ! function_exists('index_page'))
{
+ /**
+ * Index page
+ *
+ * Returns the "index_page" from your config file
+ *
+ * @return string
+ */
function index_page()
{
- $CI =& get_instance();
- return $CI->config->item('index_page');
+ return get_instance()->config->item('index_page');
}
}
// ------------------------------------------------------------------------
-/**
- * Anchor Link
- *
- * Creates an anchor based on the local URL.
- *
- * @access public
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('anchor'))
{
+ /**
+ * Anchor Link
+ *
+ * Creates an anchor based on the local URL.
+ *
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function anchor($uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
- if ( ! is_array($uri))
- {
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
- }
- else
- {
- $site_url = site_url($uri);
- }
+ $site_url = is_array($uri)
+ ? site_url($uri)
+ : (preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri));
- if ($title == '')
+ if ($title === '')
{
$title = $site_url;
}
- if ($attributes != '')
+ if ($attributes !== '')
{
- $attributes = _parse_attributes($attributes);
+ $attributes = _stringify_attributes($attributes);
}
return ''.$title.' ';
@@ -170,139 +179,141 @@ function anchor($uri = '', $title = '', $attributes = '')
// ------------------------------------------------------------------------
-/**
- * Anchor Link - Pop-up version
- *
- * Creates an anchor based on the local URL. The link
- * opens a new window based on the attributes specified.
- *
- * @access public
- * @param string the URL
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('anchor_popup'))
{
+ /**
+ * Anchor Link - Pop-up version
+ *
+ * Creates an anchor based on the local URL. The link
+ * opens a new window based on the attributes specified.
+ *
+ * @param string the URL
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
+ $site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
- $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
-
- if ($title == '')
+ if ($title === '')
{
$title = $site_url;
}
if ($attributes === FALSE)
{
- return "".$title." ";
+ return '".$title.' ';
}
if ( ! is_array($attributes))
{
- $attributes = array();
- }
+ $attributes = array($attributes);
- foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val)
+ // Ref: http://www.w3schools.com/jsref/met_win_open.asp
+ $window_name = '_blank';
+ }
+ elseif ( ! empty($attributes['window_name']))
{
- $atts[$key] = ( ! isset($attributes[$key])) ? $val : $attributes[$key];
- unset($attributes[$key]);
+ $window_name = $attributes['window_name'];
+ unset($attributes['window_name']);
+ }
+ else
+ {
+ $window_name = '_blank';
}
- if ($attributes != '')
+ foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'menubar' => 'no', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0') as $key => $val)
{
- $attributes = _parse_attributes($attributes);
+ $atts[$key] = isset($attributes[$key]) ? $attributes[$key] : $val;
+ unset($attributes[$key]);
}
- return "".$title." ";
+ $attributes = _stringify_attributes($attributes);
+
+ return ''.$title.' ';
}
}
// ------------------------------------------------------------------------
-/**
- * Mailto Link
- *
- * @access public
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('mailto'))
{
+ /**
+ * Mailto Link
+ *
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
- if ($title == "")
+ if ($title === '')
{
$title = $email;
}
- $attributes = _parse_attributes($attributes);
-
- return ''.$title.' ';
+ return ''.$title.' ';
}
}
// ------------------------------------------------------------------------
-/**
- * Encoded Mailto Link
- *
- * Create a spam-protected mailto link written in Javascript
- *
- * @access public
- * @param string the email address
- * @param string the link title
- * @param mixed any attributes
- * @return string
- */
if ( ! function_exists('safe_mailto'))
{
+ /**
+ * Encoded Mailto Link
+ *
+ * Create a spam-protected mailto link written in Javascript
+ *
+ * @param string the email address
+ * @param string the link title
+ * @param mixed any attributes
+ * @return string
+ */
function safe_mailto($email, $title = '', $attributes = '')
{
$title = (string) $title;
- if ($title == "")
+ if ($title === '')
{
$title = $email;
}
- for ($i = 0; $i < 16; $i++)
- {
- $x[] = substr(' $val)
{
- $x[] = ' '.$key.'="';
- for ($i = 0; $i < strlen($val); $i++)
+ $x[] = ' '.$key.'="';
+ for ($i = 0, $l = strlen($val); $i < $l; $i++)
{
- $x[] = "|".ord(substr($val, $i, 1));
+ $x[] = '|'.ord($val[$i]);
}
$x[] = '"';
}
}
else
{
- for ($i = 0; $i < strlen($attributes); $i++)
+ for ($i = 0, $l = strlen($attributes); $i < $l; $i++)
{
- $x[] = substr($attributes, $i, 1);
+ $x[] = $attributes[$i];
}
}
}
@@ -310,26 +321,28 @@ function safe_mailto($email, $title = '', $attributes = '')
$x[] = '>';
$temp = array();
- for ($i = 0; $i < strlen($title); $i++)
+ for ($i = 0, $l = strlen($title); $i < $l; $i++)
{
$ordinal = ord($title[$i]);
if ($ordinal < 128)
{
- $x[] = "|".$ordinal;
+ $x[] = '|'.$ordinal;
}
else
{
- if (count($temp) == 0)
+ if (count($temp) === 0)
{
$count = ($ordinal < 224) ? 2 : 3;
}
$temp[] = $ordinal;
- if (count($temp) == $count)
+ if (count($temp) === $count)
{
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
- $x[] = "|".$number;
+ $number = ($count === 3)
+ ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64)
+ : (($temp[0] % 32) * 64) + ($temp[1] % 64);
+ $x[] = '|'.$number;
$count = 1;
$temp = array();
}
@@ -339,89 +352,75 @@ function safe_mailto($email, $title = '', $attributes = '')
$x[] = '<'; $x[] = '/'; $x[] = 'a'; $x[] = '>';
$x = array_reverse($x);
- ob_start();
-
- ?>\n"
+ ."\t//= 0; i=i-1) {\n"
+ ."\t\tif (l[i].substring(0, 1) === '|') document.write(\"\"+unescape(l[i].substring(1))+\";\");\n"
+ ."\t\telse document.write(unescape(l[i]));\n"
+ ."\t}\n"
+ ."\t//]]>\n"
+ .'';
+
+ return $output;
}
}
// ------------------------------------------------------------------------
-/**
- * Auto-linker
- *
- * Automatically links URL and Email addresses.
- * Note: There's a bit of extra code here to deal with
- * URLs or emails that end in a period. We'll strip these
- * off and add them after the link.
- *
- * @access public
- * @param string the string
- * @param string the type: email, url, or both
- * @param bool whether to create pop-up links
- * @return string
- */
if ( ! function_exists('auto_link'))
{
+ /**
+ * Auto-linker
+ *
+ * Automatically links URL and Email addresses.
+ * Note: There's a bit of extra code here to deal with
+ * URLs or emails that end in a period. We'll strip these
+ * off and add them after the link.
+ *
+ * @param string the string
+ * @param string the type: email, url, or both
+ * @param bool whether to create pop-up links
+ * @return string
+ */
function auto_link($str, $type = 'both', $popup = FALSE)
{
- if ($type != 'email')
+ // Find and replace any URLs.
+ if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER))
{
- if (preg_match_all("#(^|\s|\()((http(s?)://)|(www\.))(\w+[^\s\)\<]+)#i", $str, $matches))
- {
- $pop = ($popup == TRUE) ? " target=\"_blank\" " : "";
+ // Set our target HTML if using popup links.
+ $target = ($popup) ? ' target="_blank" rel="noopener"' : '';
- for ($i = 0; $i < count($matches['0']); $i++)
- {
- $period = '';
- if (preg_match("|\.$|", $matches['6'][$i]))
- {
- $period = '.';
- $matches['6'][$i] = substr($matches['6'][$i], 0, -1);
- }
-
- $str = str_replace($matches['0'][$i],
- $matches['1'][$i].' http'.
- $matches['4'][$i].'://'.
- $matches['5'][$i].
- $matches['6'][$i].' '.
- $period, $str);
- }
+ // We process the links in reverse order (last -> first) so that
+ // the returned string offsets from preg_match_all() are not
+ // moved as we add more HTML.
+ foreach (array_reverse($matches) as $match)
+ {
+ // $match[0] is the matched string/link
+ // $match[1] is either a protocol prefix or 'www.'
+ //
+ // With PREG_OFFSET_CAPTURE, both of the above is an array,
+ // where the actual value is held in [0] and its offset at the [1] index.
+ $a = ''.$match[0][0].' ';
+ $str = substr_replace($str, $a, $match[0][1], strlen($match[0][0]));
}
}
- if ($type != 'url')
+ // Find and replace any emails.
+ if ($type !== 'url' && preg_match_all('#([\w\.\-\+]+@[a-z0-9\-]+\.[a-z0-9\-\.]+[^[:punct:]\s])#i', $str, $matches, PREG_OFFSET_CAPTURE))
{
- if (preg_match_all("/([a-zA-Z0-9_\.\-\+]+)@([a-zA-Z0-9\-]+)\.([a-zA-Z0-9\-\.]*)/i", $str, $matches))
+ foreach (array_reverse($matches[0]) as $match)
{
- for ($i = 0; $i < count($matches['0']); $i++)
+ if (filter_var($match[0], FILTER_VALIDATE_EMAIL) !== FALSE)
{
- $period = '';
- if (preg_match("|\.$|", $matches['3'][$i]))
- {
- $period = '.';
- $matches['3'][$i] = substr($matches['3'][$i], 0, -1);
- }
-
- $str = str_replace($matches['0'][$i], safe_mailto($matches['1'][$i].'@'.$matches['2'][$i].'.'.$matches['3'][$i]).$period, $str);
+ $str = substr_replace($str, safe_mailto($match[0]), $match[1], strlen($match[0]));
}
}
}
@@ -432,20 +431,19 @@ function auto_link($str, $type = 'both', $popup = FALSE)
// ------------------------------------------------------------------------
-/**
- * Prep URL
- *
- * Simply adds the http:// part if no scheme is included
- *
- * @access public
- * @param string the URL
- * @return string
- */
if ( ! function_exists('prep_url'))
{
+ /**
+ * Prep URL
+ *
+ * Simply adds the http:// part if no scheme is included
+ *
+ * @param string the URL
+ * @return string
+ */
function prep_url($str = '')
{
- if ($str == 'http://' OR $str == '')
+ if ($str === 'http://' OR $str === '')
{
return '';
}
@@ -454,7 +452,7 @@ function prep_url($str = '')
if ( ! $url OR ! isset($url['scheme']))
{
- $str = 'http://'.$str;
+ return 'http://'.$str;
}
return $str;
@@ -463,45 +461,46 @@ function prep_url($str = '')
// ------------------------------------------------------------------------
-/**
- * Create URL Title
- *
- * Takes a "title" string as input and creates a
- * human-friendly URL string with a "separator" string
- * as the word separator.
- *
- * @access public
- * @param string the string
- * @param string the separator
- * @return string
- */
if ( ! function_exists('url_title'))
{
+ /**
+ * Create URL Title
+ *
+ * Takes a "title" string as input and creates a
+ * human-friendly URL string with a "separator" string
+ * as the word separator.
+ *
+ * @todo Remove old 'dash' and 'underscore' usage in 3.1+.
+ * @param string $str Input string
+ * @param string $separator Word separator
+ * (usually '-' or '_')
+ * @param bool $lowercase Whether to transform the output string to lowercase
+ * @return string
+ */
function url_title($str, $separator = '-', $lowercase = FALSE)
{
- if ($separator == 'dash')
+ if ($separator === 'dash')
{
- $separator = '-';
+ $separator = '-';
}
- else if ($separator == 'underscore')
+ elseif ($separator === 'underscore')
{
- $separator = '_';
+ $separator = '_';
}
-
- $q_separator = preg_quote($separator);
+
+ $q_separator = preg_quote($separator, '#');
$trans = array(
- '&.+?;' => '',
- '[^a-z0-9 _-]' => '',
- '\s+' => $separator,
- '('.$q_separator.')+' => $separator
+ '&.+?;' => '',
+ '[^\w\d _-]' => '',
+ '\s+' => $separator,
+ '('.$q_separator.')+' => $separator
);
$str = strip_tags($str);
-
foreach ($trans as $key => $val)
{
- $str = preg_replace("#".$key."#i", $val, $str);
+ $str = preg_replace('#'.$key.'#i'.(UTF8_ENABLED ? 'u' : ''), $val, $str);
}
if ($lowercase === TRUE)
@@ -509,87 +508,62 @@ function url_title($str, $separator = '-', $lowercase = FALSE)
$str = strtolower($str);
}
- return trim($str, $separator);
+ return trim(trim($str, $separator));
}
}
// ------------------------------------------------------------------------
-/**
- * Header Redirect
- *
- * Header redirect in two flavors
- * For very fine grained control over headers, you could use the Output
- * Library's set_header() function.
- *
- * @access public
- * @param string the URL
- * @param string the method: location or redirect
- * @return string
- */
if ( ! function_exists('redirect'))
{
- function redirect($uri = '', $method = 'location', $http_response_code = 302)
+ /**
+ * Header Redirect
+ *
+ * Header redirect in two flavors
+ * For very fine grained control over headers, you could use the Output
+ * Library's set_header() function.
+ *
+ * @param string $uri URL
+ * @param string $method Redirect method
+ * 'auto', 'location' or 'refresh'
+ * @param int $code HTTP Response status code
+ * @return void
+ */
+ function redirect($uri = '', $method = 'auto', $code = NULL)
{
- if ( ! preg_match('#^https?://#i', $uri))
+ if ( ! preg_match('#^(\w+:)?//#i', $uri))
{
$uri = site_url($uri);
}
- switch($method)
- {
- case 'refresh' : header("Refresh:0;url=".$uri);
- break;
- default : header("Location: ".$uri, TRUE, $http_response_code);
- break;
- }
- exit;
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * Parse out the attributes
- *
- * Some of the functions use this
- *
- * @access private
- * @param array
- * @param bool
- * @return string
- */
-if ( ! function_exists('_parse_attributes'))
-{
- function _parse_attributes($attributes, $javascript = FALSE)
- {
- if (is_string($attributes))
+ // IIS environment likely? Use 'refresh' for better compatibility
+ if ($method === 'auto' && isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== FALSE)
{
- return ($attributes != '') ? ' '.$attributes : '';
+ $method = 'refresh';
}
-
- $att = '';
- foreach ($attributes as $key => $val)
+ elseif ($method !== 'refresh' && (empty($code) OR ! is_numeric($code)))
{
- if ($javascript == TRUE)
+ if (isset($_SERVER['SERVER_PROTOCOL'], $_SERVER['REQUEST_METHOD']) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1')
{
- $att .= $key . '=' . $val . ',';
+ $code = ($_SERVER['REQUEST_METHOD'] !== 'GET')
+ ? 303 // reference: http://en.wikipedia.org/wiki/Post/Redirect/Get
+ : 307;
}
else
{
- $att .= ' ' . $key . '="' . $val . '"';
+ $code = 302;
}
}
- if ($javascript == TRUE AND $att != '')
+ switch ($method)
{
- $att = substr($att, 0, -1);
+ case 'refresh':
+ header('Refresh:0;url='.$uri);
+ break;
+ default:
+ header('Location: '.$uri, TRUE, $code);
+ break;
}
-
- return $att;
+ exit;
}
}
-
-
-/* End of file url_helper.php */
-/* Location: ./system/helpers/url_helper.php */
\ No newline at end of file
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 9c1fadb..2639956 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -1,20 +1,41 @@
-","\"", "'", "-"),
- array("&", "<", ">", """, "'", "-"),
- $str);
+ $str = str_replace(
+ array('&', '<', '>', '"', "'", '-'),
+ array('&', '<', '>', '"', ''', '-'),
+ $str
+ );
// Decode the temp markers back to entities
- $str = preg_replace("/$temp(\d+);/","\\1;",$str);
+ $str = preg_replace('/'.$temp.'(\d+);/', '\\1;', $str);
if ($protect_all === TRUE)
{
- $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+ return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str);
}
return $str;
}
}
-
-// ------------------------------------------------------------------------
-
-/* End of file xml_helper.php */
-/* Location: ./system/helpers/xml_helper.php */
\ No newline at end of file
diff --git a/system/index.html b/system/index.html
index c942a79..b702fbc 100644
--- a/system/index.html
+++ b/system/index.html
@@ -1,3 +1,4 @@
+
403 Forbidden
@@ -7,4 +8,4 @@
Directory access is forbidden.
-
\ No newline at end of file
+