First public commit

This commit is contained in:
Timothy Warren 2014-08-08 15:41:59 -04:00
commit b48acc6c61
1528 changed files with 87833 additions and 0 deletions

6
.gitignore vendored Executable file
View File

@ -0,0 +1,6 @@
web/cron.log
application/logs/*.php
application/cache/*
web/coverage/*
vendor/*
composer.lock

0
README.md Normal file
View File

123
application/config/autoload.php Executable file
View File

@ -0,0 +1,123 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
|
| In order to keep the framework as light-weight as possible only the
| absolute minimal resources are loaded by default. For example,
| the database is not connected to automatically since no assumption
| is made regarding whether you intend to use it. This file lets
| you globally define which systems you would like loaded with every
| request.
|
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Libraries
| 2. Helper files
| 3. Plugins
| 4. Custom config files
| 5. Language files
| 6. Models
|
*/
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in the system/libraries folder
| or in your system/application/libraries folder.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
*/
$autoload['libraries'] = [
'database',
'page',
'todo',
'session',
'form_validation',
'validation_callbacks'
];
/*
| -------------------------------------------------------------------
| Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url', 'html', 'security', 'form');
/*
| -------------------------------------------------------------------
| Auto-load Plugins
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['plugin'] = array('captcha', 'js_calendar');
*/
$autoload['plugin'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files. Otherwise, leave it blank.
|
*/
$autoload['config'] = array('sites');
/*
| -------------------------------------------------------------------
| Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file. For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['model'] = array('model1', 'model2');
|
*/
$autoload['model'] = array();
/* End of file autoload.php */
/* Location: ./application/config/autoload.php */

350
application/config/config.php Executable file
View File

@ -0,0 +1,350 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
*/
$config['base_url'] = 'https://todo.timshomepage.net/';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "";
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of "AUTO" works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = "REQUEST_URI";
/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/urls.html
*/
$config['url_suffix'] = "";
/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
|
| This determines which set of language files should be used. Make sure
| there is an available translation if you intend to use something other
| than english.
|
*/
$config['language'] = "english";
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
*/
$config['charset'] = "UTF-8";
/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the "hooks" feature you must enable it by
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = TRUE;
/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries. For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/core_classes.html
| http://codeigniter.com/user_guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'MY_';
/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify with a regular expression which characters are permitted
| within your URLs. When someone tries to submit a URL with disallowed
| characters they will get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
/*
|--------------------------------------------------------------------------
| Enable Query Strings
|--------------------------------------------------------------------------
|
| By default CodeIgniter uses search-engine friendly segment based URLs:
| example.com/who/what/where/
|
| You can optionally enable standard query string based URLs:
| example.com?who=me&what=something&where=here
|
| Options are: TRUE or FALSE (boolean)
|
| The other items let you set the query string "words" that will
| invoke your controllers and its functions:
| example.com/index.php?c=controller&m=function
|
| Please note that some of the helpers won't work as expected when
| this feature is enabled, since CodeIgniter is designed primarily to
| use segment based URLs.
|
*/
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd'; // experimental not currently in use
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| If you have enabled error logging, you can set an error threshold to
| determine what gets logged. Threshold options are:
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 1;
/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| system/logs/ folder. Use a full server path with trailing slash.
|
*/
$config['log_path'] = '';
/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
$config['log_date_format'] = 'Y-m-d H:i:s';
/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| system/cache/ folder. Use a full server path with trailing slash.
|
*/
$config['cache_path'] = '';
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| If you use the Encryption class or the Sessions class with encryption
| enabled you MUST set an encryption key. See the user guide for info.
|
*/
$config['encryption_key'] = "xLx45kOkywjdvvVMxLov";
/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'session_cookie_name' = the name you want for the cookie
| 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie
| 'session_expiration' = the number of SECONDS you want the session to last.
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
| 'time_to_update' = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name'] = 'sess';
$config['sess_expiration'] = 43200; //12 hours
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
|
*/
$config['cookie_prefix'] = "thp_todo_";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['cookie_secure'] = TRUE;
/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
|
| Determines whether the XSS filter is always active when GET, POST or
| COOKIE data is encountered
|
*/
$config['global_xss_filtering'] = FALSE;
/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| 'csrf_token_name' = The token name
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.
*/
$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'csrf_token';
$config['csrf_cookie_name'] = 'csrf_cookie';
$config['csrf_expire'] = 7200;
/*
|--------------------------------------------------------------------------
| Output Compression
|--------------------------------------------------------------------------
|
| Enables Gzip output compression for faster page loads. When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
|
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts. For
| compression to work, nothing can be sent before the output buffer is called
| by the output class. Do not "echo" any values with compression enabled.
|
*/
$config['compress_output'] = TRUE;
/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
| Options are "local" or "gmt". This pref tells the system whether to use
| your server's local time as the master "now" reference, or convert it to
| GMT. See the "date helper" page of the user guide for information
| regarding date handling.
|
*/
$config['time_reference'] = 'local';
/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files. Options are TRUE or FALSE (boolean)
|
*/
$config['rewrite_short_tags'] = FALSE;
/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy IP
| addresses from which CodeIgniter should trust the HTTP_X_FORWARDED_FOR
| header in order to properly identify the visitor's IP address.
| Comma-delimited, e.g. '10.0.1.200,10.0.1.201'
|
*/
$config['proxy_ips'] = '';
/* End of file config.php */
/* Location: ./system/application/config/config.php */

114
application/config/constants.php Executable file
View File

@ -0,0 +1,114 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Kanji Constants
|--------------------------------------------------------------------------
|
| Constants defining equivalent kanji for arabic numerals
|
*/
define('ZERO', '');
define('ONE', '一');
define('TWO', '二');
define('THREE', '三');
define('FOUR', '四');
define('FIVE', '五');
define('SIX', '六');
define('SEVEN', '七');
define('EIGHT', '八');
define('NINE', '九');
define('TEN', '十');
define('HUNDRED', '百');
define('THOUSAND', '千');
define('TEN_THOUSAND', '万');
define('HUNDRED_MILLION', '億');
/*
|--------------------------------------------------------------------------
| TYPE Constants
|--------------------------------------------------------------------------
|
| Constants defining magic numbers
|
*/
// Status constants
define('STATUS_CREATED', 1);
define('STATUS_COMPLETED', 2);
define('STATUS_IN_PROGRESS', 3);
define('STATUS_ON_HOLD', 4);
define('STATUS_CANCELED', 5);
// Permission constants
define('PERM_NO_ACCESS', -1);
define('PERM_READ_ACCESS', 0);
define('PERM_COMMENT_ACCESS',1);
define('PERM_CHECKLIST_ACCESS', 2);
define('PERM_WRITE_ACCESS', 3);
define('PERM_ADMIN_ACCESS', 9);
// Friend constants
define('FRIEND_NOT_CONFIRMED', -1);
define('FRIEND_CONFIRMED', 1);
define('FRIEND_REJECTED', 0);
/*
|--------------------------------------------------------------------------
| Formatting Constants
|--------------------------------------------------------------------------
|
| Constants for the Page library
|
*/
//Define some constants for formatting
define('NL', "\n");
define('T1', "\t");
define('T2', T1.T1);
define('T3', T2.T1);
define('T4', T2.T2);
define('T5', T3.T2);
define('T6', T3.T3);
/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
|
| These prefs are used when checking and setting modes when working
| with the file system. The defaults are fine on servers with proper
| security, but you may wish (or even need) to change the values in
| certain environments (Apache running a separate process for each
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
| always be used to set the mode correctly.
|
*/
define('FILE_READ_MODE', 0644);
define('FILE_WRITE_MODE', 0666);
define('DIR_READ_MODE', 0755);
define('DIR_WRITE_MODE', 0777);
/*
|--------------------------------------------------------------------------
| File Stream Modes
|--------------------------------------------------------------------------
|
| These modes are used when working with fopen()/popen()
|
*/
define('FOPEN_READ', 'rb');
define('FOPEN_READ_WRITE', 'r+b');
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
define('FOPEN_WRITE_CREATE', 'ab');
define('FOPEN_READ_WRITE_CREATE', 'a+b');
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
/* End of file constants.php */
/* Location: ./system/application/config/constants.php */

62
application/config/database.php Executable file
View File

@ -0,0 +1,62 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the "Database Connection"
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
|
| The $active_group variable lets you choose which connection group to
| make active. By mysql there is only one group (the "mysql" group).
|
| The $active_record variables lets you determine whether or not to load
| the active record class
*/
$active_group = "todo";
$active_record = TRUE;
$db = [
'todo' => [
'hostname' => 'localhost',
'username' => 'todo',
'password' => 'todo',
'database' => 'todo',
'dbdriver' => 'postgre',
'dbprefix' => 'todo_',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => TRUE,
'stricton' => FALSE
],
];
/* End of file database.php */
/* Location: ./system/application/config/database.php */

17
application/config/doctypes.php Executable file
View File

@ -0,0 +1,17 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$_doctypes = array(
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml11svg' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'
);
/* End of file doctypes.php */
/* Location: application/config/doctypes.php */

View File

@ -0,0 +1,67 @@
<?php
$config = [
'task' => [
[
'field' => 'title',
'label' => 'Title',
'rules' => 'required|min_length[1]|max_length[255]|xss_clean'
],
[
'field' => 'desc',
'label' => 'Description',
'rules' => 'required|min_length[1]|xss_clean'
],
[
'field' => 'category',
'label' => 'Category',
'rules' => 'required|is_natural_no_zero'
],
[
'field' => 'priority',
'label' => 'Priority',
'rules' => 'required|is_natural'
],
[
'field' => 'due_hour',
'label' => 'Due Hour',
'rules' => 'min_length[1]|less_than[24]|is_natural'
],
[
'field' => 'due_minute',
'label' => 'Due Minute',
'rules' => 'min_length[1]|less_than[61]|is_natural'
],
[
'field' => 'due',
'label' => 'Due Date',
'rules' => 'callback_validate[due_date]'
],
[
'field' => 'reminder',
'label' => 'Reminder',
'rules' => ''
]
],
'login/register' => [
[
'field' => 'email',
'label' => 'Email Address',
'rules' => 'required|callback_validate[valid_email]|is_unique[user.email]'
],
[
'field' => 'user',
'label' => 'Username',
'rules' => 'required|is_unique[user.username]'
],
[
'field' => 'pass',
'label' => 'Password',
'rules' => 'required',
],
[
'field' => 'pass1',
'label' => 'Password Confirmation',
'rules' => 'required|matches[pass]',
]
]
];

23
application/config/hooks.php Executable file
View File

@ -0,0 +1,23 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
| files. Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/hooks.html
|
*/
$hook['post_controller_constructor'][] = array(
'class' => '',
'function' => 'check_session',
'filename' => 'pre-controller.php',
'filepath' => 'hooks'
);
/* End of file hooks.php */
/* Location: ./system/application/config/hooks.php */

10
application/config/index.html Executable file
View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

105
application/config/mimes.php Executable file
View File

@ -0,0 +1,105 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types. It is used by the
| Upload class to help identify allowed file types.
|
*/
$mimes = array( 'hqx' => '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', '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' => 'application/octet-stream',
'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' => 'application/x-tar',
'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'),
'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' => 'audio/x-wav',
'bmp' => 'image/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' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822'
);
/* End of file mimes.php */
/* Location: ./system/application/config/mimes.php */

144
application/config/min_config.php Executable file
View File

@ -0,0 +1,144 @@
<?php
/**
* Configuration for default Minify application
* @package Minify
*/
/**
* In 'debug' mode, Minify can combine files with no minification and
* add comments to indicate line #s of the original files.
*
* To allow debugging, set this option to true and add "&debug=1" to
* a URI. E.g. /min/?f=script1.js,script2.js&debug=1
*/
$min_allowDebugFlag = true;
/**
* Set to true to log messages to FirePHP (Firefox Firebug addon).
* Set to false for no error logging (Minify may be slightly faster).
* @link http://www.firephp.org/
*
* If you want to use a custom error logger, set this to your logger
* instance. Your object should have a method log(string $message).
*
* @todo cache system does not have error logging yet.
*/
$min_errorLogger = false;
/**
* For best performance, specify your temp directory here. Otherwise Minify
* will have to load extra code to guess. Some examples below:
*/
$min_cachePath = realpath(dirname(__FILE__) . '/../../application/cache');
/**
* Leave an empty string to use PHP's $_SERVER['DOCUMENT_ROOT'].
*
* On some servers, this value may be misconfigured or missing. If so, set this
* to your full document root path with no trailing slash.
* E.g. '/home/accountname/public_html' or 'c:\\xampp\\htdocs'
*
* If /min/ is directly inside your document root, just uncomment the
* second line. The third line might work on some Apache servers.
*/
$min_documentRoot = '';
//$min_documentRoot = substr(__FILE__, 0, strlen(__FILE__) - 15);
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
/**
* Cache file locking. Set to false if filesystem is NFS. On at least one
* NFS system flock-ing attempts stalled PHP for 30 seconds!
*/
$min_cacheFileLocking = true;
/**
* Combining multiple CSS files can place @import declarations after rules, which
* is invalid. Minify will attempt to detect when this happens and place a
* warning comment at the top of the CSS output. To resolve this you can either
* move the @imports within your CSS files, or enable this option, which will
* move all @imports to the top of the output. Note that moving @imports could
* affect CSS values (which is why this option is disabled by default).
*/
$min_serveOptions['bubbleCssImports'] = false;
/**
* Maximum age of browser cache in seconds. After this period, the browser
* will send another conditional GET. Use a longer period for lower traffic
* but you may want to shorten this before making changes if it's crucial
* those changes are seen immediately.
*
* Note: Despite this setting, if you include a number at the end of the
* querystring, maxAge will be set to one year. E.g. /min/f=hello.css&123456
*/
$min_serveOptions['maxAge'] = 1800;
/**
* If you'd like to restrict the "f" option to files within/below
* particular directories below DOCUMENT_ROOT, set this here.
* You will still need to include the directory in the
* f or b GET parameters.
*
* // = shortcut for DOCUMENT_ROOT
*/
//$min_serveOptions['minApp']['allowDirs'] = array('//js', '//css');
/**
* Set to true to disable the "f" GET parameter for specifying files.
* Only the "g" parameter will be considered.
*/
$min_serveOptions['minApp']['groupsOnly'] = false;
/**
* Maximum # of files that can be specified in the "f" GET parameter
*/
$min_serveOptions['minApp']['maxFiles'] = 10;
/**
* If you minify CSS files stored in symlink-ed directories, the URI rewriting
* algorithm can fail. To prevent this, provide an array of link paths to
* target paths, where the link paths are within the document root.
*
* Because paths need to be normalized for this to work, use "//" to substitute
* the doc root in the link paths (the array keys). E.g.:
* <code>
* array('//symlink' => '/real/target/path') // unix
* array('//static' => 'D:\\staticStorage') // Windows
* </code>
*/
$min_symlinks = array(
);
/**
* If you upload files from Windows to a non-Windows server, Windows may report
* incorrect mtimes for the files. This may cause Minify to keep serving stale
* cache files when source file changes are made too frequently (e.g. more than
* once an hour).
*
* Immediately after modifying and uploading a file, use the touch command to
* update the mtime on the server. If the mtime jumps ahead by a number of hours,
* set this variable to that number. If the mtime moves back, this should not be
* needed.
*
* In the Windows SFTP client WinSCP, there's an option that may fix this
* issue without changing the variable below. Under login > environment,
* select the option "Adjust remote timestamp with DST".
* @link http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time
*/
$min_uploaderHoursBehind = 0;
// try to disable output_compression (may not have an effect)
ini_set('zlib.output_compression', '0');
//Use JSMin+
$min_serveOptions['minifiers']['application/x-javascript'] = array('JSMinPlus', 'minify');

View File

@ -0,0 +1,36 @@
<?php
/**
* Groups configuration for default Minify implementation
* @package Minify
*/
$root = "//";
return array(
/*-----
Css
-----*/
'css' => array(
$root. 'fonts/Puritan/stylesheet.css',
$root. 'css/todo.css',
$root. 'css/message.css',
$root. 'js/CLEditor/jquery.cleditor.css',
$root. 'css/jquery-ui.min.css'
),
/*-----
Javascript
-----*/
'js' => array(
$root. 'js/CLEditor/jquery.cleditor.js',
$root. 'js/CLEditor/jquery.cleditor.xhtml.js',
$root. 'js/todo.js',
),
'js_mobile' => array(
$root. 'js/todo.js',
),
);

53
application/config/profiler.php Executable file
View File

@ -0,0 +1,53 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
*
* Licensed under the Academic Free License version 3.0
*
* This source file is subject to the Academic Free License (AFL 3.0) that is
* bundled with this package in the files license_afl.txt / license_afl.rst.
* It is also available through the world wide web at this URL:
* http://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to obtain it
* through the world wide web, please send an email to
* licensing@ellislab.com so we can send you a copy immediately.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
* @license http://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
/*
| -------------------------------------------------------------------------
| Profiler Sections
| -------------------------------------------------------------------------
| This file lets you determine whether or not various sections of Profiler
| data are displayed when the Profiler is enabled.
| Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/profiling.html
|
*/
$config['config'] = FALSE;
$config['http_headers'] = FALSE;
$config['uri_string'] = FALSE;
$config['get'] = FALSE;
$config['controller_info'] = FALSE;
$config['session_data'] = FALSE;
$config['post'] = FALSE;
$config['benchmarks'] = FALSE;
$config['memory_usage'] = FALSE;
$config['query_toggle_count'] = 1;
/* End of file profiler.php */
/* Location: ./application/config/profiler.php */

54
application/config/routes.php Executable file
View File

@ -0,0 +1,54 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
*/
$route = [
'default_controller' => 'login',
'logout' => 'login/logout',
'login' => 'login/do_login',
'register' => 'login/register',
'task/list' => 'task/list_tasks',
'friend/list' => 'friend/friend_list',
'category/list' => 'category/category_list',
'task/category/list' => 'category/category_list',
'task/calendar' => 'calendar/index',
'task/calendar/:any' => 'calendar/index',
'task/archive/:num' => 'task/archive',
'404_overide' => ''
];
/* End of file routes.php */
/* Location: ./system/application/config/routes.php */

119
application/config/sites.php Executable file
View File

@ -0,0 +1,119 @@
<?php
include "config.php";
/*
|--------------------------------------------------------------------------
| Content Domain
|--------------------------------------------------------------------------
|
| This is the domain used for serving content, such as css, javascript.
|
*/
$config['content_domain'] = $config['base_url'];
/*
|--------------------------------------------------------------------------
| Content Domain
|--------------------------------------------------------------------------
|
| This is the domain/subdomain used for serving images.
|
*/
$config['image_domain'] = $config['content_domain'].'/images';
/*
|--------------------------------------------------------------------------
| Static Lib Path
|--------------------------------------------------------------------------
|
| This is the path where the 'libs' directory is on the static domain.
|
*/
$config['static_lib_path'] = $config['content_domain'];
/*
|--------------------------------------------------------------------------
| Group Style/Javascript Path
|--------------------------------------------------------------------------
|
| This is the path that is used to determine the relative path to the
| stylesheet minifier. This should not need to be changed.
|
*/
$config['group_style_path'] = $config['static_lib_path'] . 'min/index.php?g=';
/*
|--------------------------------------------------------------------------
| Default Style Path
|--------------------------------------------------------------------------
|
| This is the path that is used to determine the relative path to the
| stylesheet minifier. This should not need to be changed.
|
*/
$config['style_path'] = $config['static_lib_path'] . '/min/index.php?b=css&amp;f=';
/*
|--------------------------------------------------------------------------
| Default Javascript Path
|--------------------------------------------------------------------------
|
| This is the path that is used to determine the relative path to the
| stylesheet minifier. This should not need to be changed.
|
*/
$config['script_path'] = $config['static_lib_path'] . '/min/index.php?b=js&amp;f=';
/*
|--------------------------------------------------------------------------
| Default title
|--------------------------------------------------------------------------
|
| Default title for webpages
|
*/
$config['default_title'] = "Tim's Todo";
/*
|--------------------------------------------------------------------------
| Default css group
|--------------------------------------------------------------------------
|
| Default css group
|
*/
$config['default_js_group'] = "js";
$config['default_css_group'] = "css";
/*
|--------------------------------------------------------------------------
| Ignore IPs
|--------------------------------------------------------------------------
|
| IP address that are not counted in stats
|
*/
$config['ignore_ips'] = array('127.0.0.1');
/*
|--------------------------------------------------------------------------
| Ignore UserAgents
|--------------------------------------------------------------------------
|
| UserAgents that are not counted in stats
|
*/
$config['ignore_user_agents'] = array();
/*
|--------------------------------------------------------------------------
| Enable Reminders
|--------------------------------------------------------------------------
|
| Only enable if you can set a cron job or scheduled task for the reminder feature
|
*/
$config['enable_reminders'] = TRUE;

66
application/config/smileys.php Executable file
View File

@ -0,0 +1,66 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| SMILEYS
| -------------------------------------------------------------------
| This file contains an array of smileys for use with the emoticon helper.
| Individual images can be used to replace multiple simileys. For example:
| :-) and :) use the same image replacement.
|
| Please see user guide for more info:
| http://codeigniter.com/user_guide/helpers/smiley_helper.html
|
*/
$smileys = array(
// smiley image name width height alt
':-)' => array('grin.gif', '19', '19', 'grin'),
':lol:' => array('lol.gif', '19', '19', 'LOL'),
':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
':)' => array('smile.gif', '19', '19', 'smile'),
';-)' => array('wink.gif', '19', '19', 'wink'),
';)' => array('wink.gif', '19', '19', 'wink'),
':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
':-S' => array('confused.gif', '19', '19', 'confused'),
':wow:' => array('surprise.gif', '19', '19', 'surprised'),
':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
'%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
':P' => array('raspberry.gif', '19', '19', 'raspberry'),
':blank:' => array('blank.gif', '19', '19', 'blank stare'),
':long:' => array('longface.gif', '19', '19', 'long face'),
':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
'8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
':down:' => array('downer.gif', '19', '19', 'downer'),
':red:' => array('embarrassed.gif', '19', '19', 'red face'),
':sick:' => array('sick.gif', '19', '19', 'sick'),
':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
':-/' => array('hmm.gif', '19', '19', 'hmmm'),
'>:(' => array('mad.gif', '19', '19', 'mad'),
':mad:' => array('mad.gif', '19', '19', 'mad'),
'>:-(' => array('angry.gif', '19', '19', 'angry'),
':angry:' => array('angry.gif', '19', '19', 'angry'),
':zip:' => array('zip.gif', '19', '19', 'zipper'),
':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
':ahhh:' => array('shock.gif', '19', '19', 'shock'),
':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
':snake:' => array('snake.gif', '19', '19', 'snake'),
':exclaim:' => array('exclaim.gif', '19', '19', 'excaim'),
':question:' => array('question.gif', '19', '19', 'question') // no comma after last item
);
/* End of file smileys.php */
/* Location: ./system/application/config/smileys.php */

View File

@ -0,0 +1,62 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the "Database Connection"
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database type. ie: mysql. Currently supported:
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Active Record class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
|
| The $active_group variable lets you choose which connection group to
| make active. By mysql there is only one group (the "mysql" group).
|
| The $active_record variables lets you determine whether or not to load
| the active record class
*/
$active_group = "todo";
$active_record = TRUE;
$db = [
'todo' => [
'hostname' => 'localhost',
'username' => 'todo_test',
'password' => 'test',
'database' => 'todo_test',
'dbdriver' => 'postgre',
'dbprefix' => 'todo_',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'autoinit' => FALSE,
'stricton' => FALSE
]
];
/* End of file database.php */
/* Location: ./system/application/config/database.php */

View File

@ -0,0 +1,175 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| USER AGENT TYPES
| -------------------------------------------------------------------
| This file contains four arrays of user agent data. It is used by the
| User Agent Class to help identify browser, platform, robot, and
| mobile device data. The array keys are used to identify the device
| and the array values are used to set the actual name of the item.
|
*/
$platforms = array (
'windows nt 6.0' => 'Windows Longhorn',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.0' => 'Windows 2000',
'windows nt 5.1' => 'Windows XP',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows' => 'Unknown Windows OS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS'
);
// The order of this array should NOT be changed. Many browsers return
// multiple browser types so we want to identify the sub-type first.
$browsers = array(
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse'
);
$mobiles = array(
// legacy array, old values commented out
'mobileexplorer' => 'Mobile Explorer',
// 'openwave' => 'Open Wave',
// 'opera mini' => 'Opera Mini',
// 'operamini' => 'Opera Mini',
// 'elaine' => 'Palm',
'palmsource' => 'Palm',
// 'digital paths' => 'Palm',
// 'avantgo' => 'Avantgo',
// 'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
// 'nokia' => 'Nokia',
// 'ericsson' => 'Ericsson',
// 'blackberry' => 'BlackBerry',
// 'motorola' => 'Motorola'
// Phones and Manufacturers
'motorola' => "Motorola",
'nokia' => "Nokia",
'palm' => "Palm",
'iphone' => "Apple iPhone",
'ipod' => "Apple iPod Touch",
'sony' => "Sony Ericsson",
'ericsson' => "Sony Ericsson",
'blackberry' => "BlackBerry",
'cocoon' => "O2 Cocoon",
'blazer' => "Treo",
'lg' => "LG",
'amoi' => "Amoi",
'xda' => "XDA",
'mda' => "MDA",
'vario' => "Vario",
'htc' => "HTC",
'samsung' => "Samsung",
'sharp' => "Sharp",
'sie-' => "Siemens",
'alcatel' => "Alcatel",
'benq' => "BenQ",
'ipaq' => "HP iPaq",
'mot-' => "Motorola",
'playstation portable' => "PlayStation Portable",
'hiptop' => "Danger Hiptop",
'nec-' => "NEC",
'panasonic' => "Panasonic",
'philips' => "Philips",
'sagem' => "Sagem",
'sanyo' => "Sanyo",
'spv' => "SPV",
'zte' => "ZTE",
'sendo' => "Sendo",
// Operating Systems
'symbian' => "Symbian",
'SymbianOS' => "SymbianOS",
'elaine' => "Palm",
'palm' => "Palm",
'series60' => "Symbian S60",
'windows ce' => "Windows CE",
// Browsers
'obigo' => "Obigo",
'netfront' => "Netfront Browser",
'openwave' => "Openwave Browser",
'mobilexplorer' => "Mobile Explorer",
'operamini' => "Opera Mini",
'opera mini' => "Opera Mini",
// Other
'digital paths' => "Digital Paths",
'avantgo' => "AvantGo",
'xiino' => "Xiino",
'novarra' => "Novarra Transcoder",
'vodafone' => "Vodafone",
'docomo' => "NTT DoCoMo",
'o2' => "O2",
// Fallback
'mobile' => "Generic Mobile",
'wireless' => "Generic Mobile",
'j2me' => "Generic Mobile",
'midp' => "Generic Mobile",
'cldc' => "Generic Mobile",
'up.link' => "Generic Mobile",
'up.browser' => "Generic Mobile",
'smartphone' => "Generic Mobile",
'cellphone' => "Generic Mobile"
);
// There are hundreds of bots but these are the most common.
$robots = array(
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'askjeeves' => 'AskJeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos'
);
/* End of file user_agents.php */
/* Location: ./system/application/config/user_agents.php */

View File

@ -0,0 +1,103 @@
<?php
/**
* Account Management Controller
*/
class Account extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->page->set_foot_js_group('js');
$this->page->set_title('Account');
}
// --------------------------------------------------------------------------
/**
* Dashboard
*/
public function index()
{
$data = $this->todo->get_user_account_by_id($this->session->userdata('uid'));
$this->page->build('account/status', $data);
}
// --------------------------------------------------------------------------
/**
* Password change form
*/
public function password()
{
//Don't let the guest change the password
if($this->session->userdata('username') == 'guest')
{
$this->todo->redirect_303('account');
return;
}
if($this->input->post('pass_sub') == "Change Password")
{
$val = $this->todo->validate_pass();
if($val === TRUE)
{
$this->todo->update_pass();
//Redirect to index
$this->todo->redirect_303('task/list');
}
else
{
$data['err'] = $val;
$this->page->build('account/password', $data);
}
}
else
{
$this->page->build('account/password');
}
}
// --------------------------------------------------------------------------
/**
* Timezone update
*/
public function update_tz()
{
$timezone = $this->input->post('timezone');
$this->db->set('timezone', $timezone)
->where('id', $this->session->userdata('uid'))
->update('user');
if($this->db->affected_rows() == 1)
{
$this->output->set_output('1');
}
}
// --------------------------------------------------------------------------
/**
* Number format update
*/
public function update_nf()
{
$num_format = (int)$this->input->post('num_format');
$this->db->set('num_format', $num_format)
->where('id', $this->session->userdata('uid'))
->update('user');
if($this->db->affected_rows() == 1)
{
$this->session->set_userdata('num_format', $num_format);
$this->output->set_output('1');
}
}
}
// End of controllers/account.php

View File

@ -0,0 +1,133 @@
<?php
/**
* Calendar View Controller
*/
class Calendar extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('calendar');
$this->load->model('task_model');
}
/**
* Calendar View
*/
public function index()
{
//Output
$this->page->build('task/calendar', $this->get_calendar_data());
}
/**
* Get the data for the calendar display
*
* @return mixed
*/
protected function get_calendar_data()
{
//Offset time for custom months
if($this->uri->segment(3) && $this->uri->segment(4))
{
$year = $this->uri->segment(3);
$month = $this->uri->segment(4);
}
$_months = array(
01 => 'January', 02 => 'February',
03 => 'March', 04 => 'April',
05 => 'May', 06 => 'June',
07 => 'July', 08 => 'August',
09 => 'September', 10 => 'October',
11 => 'November', 12 => 'December',
1 => 'January', 2 => 'February',
3 => 'March', 4 => 'April',
5 => 'May', 6 => 'June',
7 => 'July', 8 => 'August',
9 => 'September',
);
$year = (isset($year)) ? $year : date('Y');
$month = (isset($month)) ? $month : date('m');
$local_time = time();
$data['month'] = $_months[(int)$month].' '.$year;
$data['calendar'] = array();
$data['today'] = getdate();
$days_in_month = $this->calendar->get_total_days($month, $year);
// Set the starting day number
$local_date = mktime(0, 0, 0, $month, 1, $year);
$month_end = mktime(0, 0, 0, $month, $days_in_month, $year);
$date = getdate($local_date);
$day = 0 + 1 - $date["wday"];
//Get tasks for each day
$content = $this->task_model->get_day_task_list($local_date, $month_end, $days_in_month);
// Set the current month/year/day
// We use this to determine the "today" date
$cur_year = date("Y", $local_time);
$cur_month = date("m", $local_time);
$cur_day = date("j", $local_time);
$is_current_month = ($cur_year == $year AND $cur_month == $month);
$out = null;
while ($day <= $days_in_month)
{
for ($i = 0; $i < 7; $i++)
{
if($i == 0)
{
$out .= '<tr>';
}
if ($day > 0 AND $day <= $days_in_month)
{
if (isset($content[$day]))
{
// Cells with content
$out .= ($is_current_month == TRUE AND $day == $cur_day) ? '<td class="today">' : '<td>';
$out .= '<div><span class="date">'.$day.'</span><ul>'.$content[$day].'</ul></div></td>';
}
else
{
// Cells with no content
$out .= ($is_current_month == TRUE AND $day == $cur_day) ? '<td class="today">' : '<td>';
$out .= '<div><span class="date">'.$day.'</span>&nbsp;</div></td>';
}
}
else
{
// Blank cells
$out .= '<td>&nbsp;</td>';
}
$day++;
if($i == 6)
{
$out .= '</tr>';
}
}
}
$data['calendar'] = $out;
return $data;
}
}

View File

@ -0,0 +1,86 @@
<?php
/**
* Category Controller
*/
class Category extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->page->set_foot_js_group('js');
$this->page->set_title('Categories');
}
/**
* Redirect to list
*/
public function index()
{
$this->todo->redirect_303(site_url('category/list'));
}
/**
* List of categories
*/
public function category_list()
{
$data['category'] = $this->todo->get_category_list();
$this->page->set_title("Category List");
$this->page->build('task/cat_list', $data);
}
/**
* Add a category
*/
public function add_sub()
{
if($this->input->post('add_sub') != FALSE)
{
$this->todo->add_category();
$this->todo->redirect_303(site_url('category/list'));
}
}
/**
* Category edit form
*/
public function edit($cat_id)
{
$data['cat'] = $this->todo->get_category((int) $cat_id);
$this->page->set_title("Edit Category");
$this->page->build('task/cat_add', $data);
}
/**
* Update the category
*/
public function edit_sub()
{
$title = $this->input->post('title', TRUE);
$desc = $this->input->post('desc', TRUE);
$cat_id = (int) $this->input->post('id');
$group_id = $this->todo->get_user_group();
$this->db->set('title', $title)
->set('description', $desc)
->where('group_id', $group_id)
->where('id', $cat_id)
->update('category');
$this->todo->redirect_303('category/list');
}
/**
* Delete a category
*/
public function del_sub($cat_id)
{
$this->output->set_output($this->todo->del_cat((int) $cat_id));
}
}
// End of controllers/category.php

View File

@ -0,0 +1,99 @@
<?php
/**
* Friend controller
*/
class Friend extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->model('friend_model');
$this->page->set_title('Friends');
$this->page->set_foot_js_group('js');
}
/**
* Alias for friend list
*/
public function index()
{
$this->friend_list();
return;
}
/**
* Get the users's friends
*/
public function friend_list()
{
$data = array();
$data['friend_list'] = $this->friend_model->get_friends();
$this->page->set_title('Friends List');
$this->page->build('friend/list', $data);
}
/**
* Friend finder form
*/
public function find()
{
$data['results'] = null;
$this->page->set_title('Find Friends');
$this->page->build('friend/search', $data);
}
/**
* Send a friend request
*/
public function add_request()
{
$friend_id = (int) $this->input->post('fid');
$this->output->set_output($this->friend_model->send_request($friend_id));
}
/**
* Accept a friend request
*/
public function accept_request()
{
$aid = xss_clean($this->input->post('aid'));
$this->output->set_output($this->friend_model->accept_request($aid));
}
/**
* Reject a friend request
*/
public function reject_request()
{
$rid = xss_clean($this->input->post('rid'));
$this->output->set_output($this->friend_model->reject_request($rid));
}
/**
* Get list of friend requests
*/
public function requests()
{
$data['request_list'] = $this->friend_model->get_requests();
$this->page->set_title('Friend Reqests');
$this->page->build('friend/requests', $data);
}
/**
* Get results for friend finder
*/
public function ajax_search()
{
$data['results'] = $this->friend_model->find_friends();
$this->load->view('friend/ajax_search', $data);
}
}
// End of controllers/friend.php

View File

@ -0,0 +1,95 @@
<?php
/**
* Group management controller
*/
class Group extends MY_Controller{
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->page->set_foot_js_group('js');
$this->page->set_title('Groups');
}
/**
* Redirect to group list
*/
public function index()
{
//303 Redirect
$this->todo->redirect_303('groups/list');
}
/**
* List of user's groups
*/
public function group_list()
{
$data['group'] = $this->todo->get_group_list((int) $this->session->userdata('uid'));
$this->page->set_title("Group List");
$this->page->build('friend/group_list', $data);
}
/**
* Add a new group
*/
public function add_sub()
{
if($this->input->post('add_sub') != FALSE)
{
$this->todo->add_group();
//Redirect to the group list
$this->todo->redirect_303('group/manage');
}
}
/**
* Delete a group
*/
public function del_group()
{
$group_id = (int) $this->uri->segment('3');
$this->output->set_output($this->todo->del_group($group_id));
}
/**
* Add/Edit a group
*/
public function manage($group_id = NULL)
{
if(is_null($group_id))
{
$this->group_list();
return;
}
if($this->input->post('friends'))
{
$this->todo->update_group();
}
$group_id = (int) $group_id;
$friends_array = array();
$array = $this->todo->get_friends_in_group($group_id);
foreach($array as $a)
{
$friends_array[] = $a['user_id'];
}
$data['group_name'] = $this->todo->get_group_name_by_id($group_id);
$data['friends'] = $this->todo->get_friend_list();
$data['selected_friends'] = $friends_array;
$data['group_perms'] = array();
$this->page->set_title("Manage Group");
$this->page->build('friend/manage', $data);
}
}
// End of controllers/group.php

114
application/controllers/login.php Executable file
View File

@ -0,0 +1,114 @@
<?php
/**
* Login Controller
*/
class Login extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->page->set_meta(array('name' =>'google-site-verification', 'content' => 'yuoqLwe6b0rP9DhTbOjuQVPRFl7RY2swO6blPPJWdMQ'));
$this->page->set_meta(array('name' => 'description', 'content' => 'Free online social task manager'));
}
// --------------------------------------------------------------------------
/**
* Alias of 'do_login'
*/
public function index()
{
if($this->session->userdata('uid') === FALSE)
{
$this->do_login();
return;
}
$this->todo->redirect_303('task/list');
}
// --------------------------------------------------------------------------
/**
* Default method of application
*/
public function do_login()
{
$data['err'] = array();
if($this->input->post('login_sub') != FALSE)
{
$res = $this->todo->verify_user();
if($res === TRUE)
{
//Redirect to the tasklist or page at before login
$login_referer = $this->session->userdata('login_referer');
$url = ($login_referer !== FALSE) ? $login_referer : 'task/list';
//Unset this for now
$this->session->unset_userdata('login_referer');
$this->todo->redirect_303($url);
}
else
{
$data['err'][] = $res;
}
}
$this->page->set_body_id('home');
$this->page->build('login/login', $data);
}
// --------------------------------------------------------------------------
/**
* Registration form and submission
*/
public function register()
{
$data = array();
if ($this->input->post('reg_sub') !== FALSE)
{
if($this->form_validation->run('login/register') === TRUE)
{
$res = $this->todo->add_reg();
if ($res == 1)
{
//Redirect to index
$this->todo->redirect_303('login');
}
show_error("Error saving registration");
}
else
{
$data['err'] = $this->form_validation->get_error_array();
$this->page->build('login/register', $data);
}
}
else
{
$data['err']='';
$this->page->build('login/register', $data);
}
}
// --------------------------------------------------------------------------
/**
* Logout action
*/
public function logout()
{
//Destroy Session
$this->session->sess_destroy();
//Redirect to index
$this->todo->redirect_303('login');
}
}
// End of controllers/login.php

View File

@ -0,0 +1,40 @@
<?php
/**
* Reminder Controller for running via Cron
*/
class Reminder extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('email');
$this->load->model('mail_model');
}
/**
* Redirect for snoops
*/
public function index()
{
//303 Redirect
$this->todo->redirect_303('task/list');
}
/**
* Check the database for reminder status
*/
public function check_reminder()
{
if(!defined('CRON'))
$this->todo->redirect_303('task/list');
//Do all the fun stuff
$this->output->set_output($this->mail_model->check_db());
}
}
// End of controllers/reminder.php

349
application/controllers/task.php Executable file
View File

@ -0,0 +1,349 @@
<?php
/**
* Task Controller
*/
class Task extends MY_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->model('task_model');
$this->load->library('pagination');
$this->page->set_title('Tasks');
$this->page->set_foot_js_group('js');
}
// --------------------------------------------------------------------------
/**
* Redirect to task list
*/
public function index()
{
$this->todo->redirect_303('task/list');
}
// --------------------------------------------------------------------------
/**
* List shared tasks
*/
public function shared()
{
$this->page->set_title("Shared Tasks");
$tasks = $this->task_model->get_shared_task_list();
$data['task_list'] = $tasks;
$data['list_type'] = "shared";
$this->page->build('task/list', $data);
}
// --------------------------------------------------------------------------
/**
* Get the main task view
*/
public function list_tasks()
{
$this->page->set_title("View Tasks");
$tasks = $this->task_model->get_task_list();
$data['task_list'] = $tasks;
$data['list_type'] = 'active';
$this->page->build('task/list', $data);
}
// --------------------------------------------------------------------------
/**
* List archived tasks
*/
public function archive($page = 1)
{
$per_page = 10;
$this->page->set_title("Archived Tasks");
$page = (int) $page;
$tasks = $this->task_model->get_archived_task_list($page, $per_page);
// Pagination preferences
$config = [
'base_url' => 'https://todo.timshomepage.net/task/archive/',
'total_rows' => $tasks['num_rows'],
'per_page' => $per_page,
'uri_segment' => 3,
'num_links' => 3,
'full_tag_open' => '<p id="pagination">',
'full_tag_close' => '</p>',
'cur_tag_open' => '<strong>',
'cur_tag_close' => '</strong>'
];
$this->pagination->initialize($config);
$data['task_list'] = $tasks;
$data['list_type'] = 'archived';
$data['pagination'] = $this->pagination->create_links();
$this->page->build('task/list', $data);
}
// --------------------------------------------------------------------------
/**
* List overdue tasks
*/
public function overdue()
{
$this->page->set_title("Overdue Tasks");
$tasks = $this->task_model->get_overdue_task_list();
$data['task_list'] = $tasks;
$data['list_type'] = 'overdue';
$this->page->build('task/list', $data);
}
// --------------------------------------------------------------------------
/**
* Add a task
*/
public function add()
{
$data = array();
$data['err'] = '';
$data['cat_list'] = $this->todo->get_category_select();
$data['pri_list'] = $this->todo->get_priority_select();
$data['group_perms'] = '';
$data['groups'] = $this->todo->get_group_list($this->session->userdata('uid'));
$data['task_title'] = '';
$data['description'] = '';
$data['due'] = mktime(12, 00, 00);
$data['title'] = '';
$data['rem_hours'] = 0;
$data['rem_minutes'] = 30;
$data['reminder'] = FALSE;
$data['friends'] = $this->todo->get_friend_list();
if ($this->input->post('add_sub') == 'Add Task')
{
$val = $this->task_model->validate_task();
if($val === TRUE)
{
$done = $this->task_model->add_task();
if ($done === TRUE)
{
//Redirect to task list
$this->todo->redirect_303('task/list');
}
else
{
$data['err'][] = "Database Error, Please try again later.";
}
}
else
{
//Get form values
$data = array_merge($data, $this->task_model->form_vals);
$data['err'] = $val;
}
}
$this->page->set_title("Add Task");
$this->page->build('task/add', $data);
}
// --------------------------------------------------------------------------
/**
* Edit a task
*
* @param int $task_id
*/
public function edit($task_id)
{
$task_id = (int) $task_id;
$data = $this->task_model->get_task_by_id($task_id);
$data['cat_list'] = $this->task_model->get_category_select($task_id);
$data['pri_list'] = $this->task_model->get_priority_select($task_id);
$data['stat_list'] = $this->task_model->get_status_select($task_id);
$data['comments'] = $this->task_model->get_task_comments($task_id);
$data['groups'] = $this->todo->get_group_list($this->session->userdata('uid'));
$data['friends'] = $this->todo->get_friend_list();
$data['checklist'] = $this->task_model->get_checklist($task_id);
if ($this->input->post('edit_sub') == 'Update Task')
{
$val = $this->task_model->validate_task();
if($val === TRUE)
{
$done = $this->task_model->update_task();
if ($done === TRUE)
{
//Redirect to task list
$this->session->set_flashdata([
'message_type' => 'success',
'message' => 'Task was updated successfully.'
]);
$this->todo->redirect_303(site_url('task/list'));
}
else
{
$data['err'][] = "Database Error, Please try again later.";
}
}
else
{
$data['err'] = $val;
}
}
$this->page->set_title("Edit Task");
$this->page->build('task/edit', $data);
}
// --------------------------------------------------------------------------
/**
* View an individual task
*
* @param int $task_id
*/
public function view($task_id = NULL)
{
if( ! is_numeric($task_id))
{
show_404();
return;
}
$task_id = (int)$task_id;
$data = $this->task_model->get_task_by_id($task_id);
$data['comments'] = $this->task_model->get_task_comments($task_id);
$data['status_id'] = $this->task_model->get_current_status_id($task_id);
$data['status'] = $this->task_model->get_status_select($task_id, $data['status_id']);
$data['category'] = $this->task_model->get_category_select($task_id);
$data['checklist'] = $this->task_model->get_checklist($task_id);
$data['task'] = $task_id;
$this->page->set_title("View Task");
$this->page->set_body_id("task_details");
$this->page->build('task/view', $data);
}
// --------------------------------------------------------------------------
/**
* Delete a task
*/
public function delete($task_id)
{
$this->task_model->delete_task((int) $task_id);
}
// --------------------------------------------------------------------------
/**
* Add a task comment
*/
public function add_task_comment()
{
$res = $this->task_model->add_task_comment($this->input->post('task_id'));
$this->output->set_output($res);
}
// --------------------------------------------------------------------------
/**
* Get a list of comments for the task
*/
public function get_task_comments()
{
$task_id = $this->input->get('task_id');
$data['comments'] = $this->task_model->get_task_comments($task_id);
$this->load->view('task/comments_view', $data);
}
// --------------------------------------------------------------------------
/**
* Delete a task comment
*/
public function del_task_comment()
{
$cid = (int) $this->input->post('comment_id');
$this->output->set_output($this->task_model->delete_comment($cid));
}
// --------------------------------------------------------------------------
/**
* Update the status of a task
*/
public function update_status()
{
$output = $this->task_model->update_status();
$this->output->set_output($output);
}
// --------------------------------------------------------------------------
/**
* Update the category that the task belongs to.
*/
public function update_category()
{
$output = $this->task_model->quick_update_category();
$this->output->set_output($output);
}
// --------------------------------------------------------------------------
/**
* Add a checklist item to the task
*/
public function add_checklist_item()
{
$data = $this->task_model->add_checklist_item();
if($data == FALSE)
{
$this->output->set_output(0);
}
else if(is_array($data))
{
$this->load->view('task/ajax_checklist', $data);
}
else
{
$this->output->set_output(-1);
}
}
// --------------------------------------------------------------------------
/**
* Update a task checklist item
*/
public function update_checklist_item()
{
$check_id = $this->input->post('check_id');
$checked = $this->input->post('checked');
$this->output->set_output($this->task_model->update_checklist($check_id, $checked));
}
}
// End of controllers/task.php

View File

@ -0,0 +1,36 @@
<?php
/**
* Base controller extending CodeIgniter Controller
*/
class MY_Controller extends CI_Controller {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
// --------------------------------------------------------------------------
/**
* Validate a form field using a callback
*
* @param string $str
* @param string $rule_name
* @return mixed
* @throws InvalidArgumentException
*/
public function validate($str, $rule_name)
{
if (method_exists($this->validation_callbacks, $rule_name))
{
return $this->validation_callbacks->$rule_name($str);
}
throw new InvalidArgumentException("Validation callback '{$rule_name}' does not exist");
}
}
// End of core/MY_Controller.php

View File

@ -0,0 +1,3 @@
<?php
header("HTTP/1.1 303 See Other");
header("Location: http://todo.timshomepage.net/task/list");

61
application/errors/error_db.php Executable file
View File

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>
<title>Database Error</title>
<style type="text/css">
*{
margin:0;
padding:0;
font-family:'Puritan2.0Normal',serif;
}
/* Declare html5 elements as block-level elements */
section, header{
display:block;
}
h1, p{
display:block;
width:80%;
margin:0 auto;
}
section, header{
background:#fff;
background:rgba(255,255,255,.65);
padding:.5%;
margin:1em;
-moz-border-radius:.5em;
-webkit-border-radius:.5em;
border-radius:.5em;
}
section{
width:90%;
margin:0 auto;
text-align:justify;
}
h1{
text-align:center;
}
html, body{
background:url('/images/bgs/blue2.png');
color:#005;
}
</style>
</head>
<body>
<header>
<figure>
<img src="/images/todo.png" alt="Tim's ToDo" id="bannerImg" />
<figcaption style="display:none;">Tim's Todo</figcaption>
</figure>
</header>
<section>
<h1><?php echo $heading; ?></h1>
<p><?php echo $message; ?><br />
<?php echo (isset($_SERVER['HTTP_REFERER'])) ? '<a href="'.$_SERVER['HTTP_REFERER'].'">Go back</a>' : '' ?></p>
</section>
</body>
</html>

View File

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style type="text/css">
*{
margin:0;
padding:0;
font-family:'Puritan2.0Normal',serif;
}
/* Declare html5 elements as block-level elements */
section, header{
display:block;
}
h1, p{
display:block;
width:80%;
margin:0 auto;
}
section, header{
background:#fff;
background:rgba(255,255,255,.65);
padding:.5%;
margin:1em;
-moz-border-radius:.5em;
-webkit-border-radius:.5em;
border-radius:.5em;
}
section{
width:90%;
margin:0 auto;
text-align:justify;
}
h1{
text-align:center;
}
html, body{
background:url('/images/bgs/blue2.png');
color:#005;
}
</style>
</head>
<body>
<header>
<figure>
<img src="/images/todo.png" alt="Tim's ToDo" id="bannerImg" />
<figcaption style="display:none;">Tim's Todo</figcaption>
</figure>
</header>
<section>
<h1><?php echo $heading; ?></h1>
<p><?php echo $message; ?><br />
<?php echo (isset($_SERVER['HTTP_REFERER'])) ? '<a href="'.$_SERVER['HTTP_REFERER'].'">Go back</a>' : '' ?></p>
</section>
</body>
</html>

View File

@ -0,0 +1,10 @@
<div style="border:1px solid #A00;background:#A00;color:#fff;-moz-border-radius:1em;border-radius:1em;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: <?php echo $severity; ?></p>
<p>Message: <?php echo $message; ?></p>
<p>Filename: <?php echo $filepath; ?></p>
<p>Line Number: <?php echo $line; ?></p>
</div>

View File

@ -0,0 +1,32 @@
<?php
/**
* Check Session
*
* Checks that the current user has a valid session, and if not, redirects
* to the login page.
* @return null
*/
function check_session()
{
$CI =& get_instance();
if($CI->session->userdata('uid') == FALSE)
{
$referer = $CI->uri->uri_string();
$white_list = [
'login',
'login/register',
'register',
'reminder/check_reminder',
];
if ( ! in_array($referer, $white_list))
{
//Redirect to login
$CI->session->set_userdata('login_referer', $referer);
$CI->todo->redirect_303('login');
}
}
}

View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@ -0,0 +1,34 @@
<?php
/**
* Add some convenience methods to form_validation library
*/
class MY_Form_validation extends CI_Form_validation {
/**
* Returns an array of errors for the current form
*
* @return array
*/
public function get_error_array()
{
return array_values($this->_error_array);
}
/**
* Clears out object data
*
* @return void
*/
public function reset()
{
foreach([
'_field_data',
'_error_array',
'_error_messages'
] as $var) {
$this->$var = array();
}
}
}
// End of libraries/MY_Form_validation.php

View File

@ -0,0 +1,81 @@
<?php
/**
* Extension of Session Library to
* allow preliminary invalidation, and json-encoded session data
*/
class MY_Session extends CI_Session {
/**
* Check if the session is valid
*
* @return bool
*/
public function session_valid()
{
$ip_address = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$ip_blacklist = [
'0.0.0.0',
'127.0.0.1'
];
$ua_blacklist = [
'false',
FALSE,
'',
'PHPUnit'
];
if (in_array($ip_address, $ip_blacklist) || in_array($user_agent, $ua_blacklist))
{
$this->sess_destroy();
return FALSE;
}
return TRUE;
}
/**
* Fetch/validate the current session data
*
* @return bool
*/
public function sess_read()
{
return ($this->session_valid()) ? parent::sess_read() : FALSE;
}
/**
* Validate the session before creation
*/
public function sess_create()
{
return ($this->session_valid()) ? parent::sess_create() : FALSE;
}
/**
* Serialize the session data to JSON
*
* @param array $data
* @return string
*/
public function _serialize($data)
{
return json_encode($data);
}
/**
* Unserialize the session data
*
* @param string $data
* @return mixed
*/
public function _unserialize($data)
{
return json_decode($data, TRUE);
}
}
/* End of file MY_Session.php */
/* Location: ./application/libraries/MY_Session.php */

297
application/libraries/Page.php Executable file
View File

@ -0,0 +1,297 @@
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/**
* Class for building pages
* @author Timothy J. Warren <tim@timshomepage.net>
*
* All methods are chainable, with the exception of the constructor,
* build_header(), build_footer(), and _headers() methods.
*/
class Page {
private static $meta, $head_js, $foot_js, $css, $title,
$head_tags, $body_id;
/**
* Current Controller Instance
*
* @var CI_Controller
*/
private $CI;
/**
* Constructor
*/
public function __construct()
{
$this->meta = "";
$this->head_js = "";
$this->foot_js = "";
$this->css = "";
$this->title = "";
$this->head_tags = "";
$this->body_id = "";
$this->CI =& get_instance();
}
// --------------------------------------------------------------------------
/**
* Sets server headers and doctype
*
* Also sets page mime type, based on if sent as
* html or xhtml, and what the target browser
* supports
*
* @return Page
*/
private function _headers()
{
$this->CI->output->set_header("Cache-Control: must-revalidate, public");
$this->CI->output->set_header("Vary: Accept");
//Predefine charset and mime
$charset = "UTF-8";
$mime = "text/html";
$doctype_string = doctype('html5') . "\n<html lang='en'>";
// finally, output the mime type and prolog type
$this->CI->output->set_header("Content-Type: $mime;charset=$charset");
$this->CI->output->set_header("X-UA-Compatible: chrome=1");
$this->CI->output->set_output($doctype_string);
return $this;
}
// --------------------------------------------------------------------------
/**
* Set Meta
*
* Sets meta tags, with codeigniter native meta tag helper
*
* @param array $meta
* @return Page
*/
public function set_meta($meta)
{
$this->meta .= T1.meta($meta).NL;
return $this;
}
// --------------------------------------------------------------------------
/**
* Sets minified javascript group in header
* @param string $group
* @param bool $debug
* @return Page
*/
public function set_head_js_group($group, $debug=FALSE)
{
$file = $this->CI->config->item('group_style_path') . $group;
$file .= ($debug == TRUE) ? "/debug/1" : "";
$this->head_js .= $this->script_tag($file, FALSE);
return $this;
}
// --------------------------------------------------------------------------
/**
* Sets a minified css group
* @param string $group
* @return Page
*/
public function set_css_group($group)
{
$link = array(
'href' => $this->CI->config->item('group_style_path') . $group,
'rel' => 'stylesheet',
'type' => 'text/css',
);
$this->css .= T1.link_tag($link).NL;
return $this;
}
// --------------------------------------------------------------------------
/**
* Sets a minified javascript group for the page footer
* @param string $group
* @return Page
*/
public function set_foot_js_group($group, $debug=FALSE)
{
$file = $this->CI->config->item('group_style_path') . $group;
$file .= ($debug == TRUE) ? "/debug/1" : "";
$this->foot_js .= $this->script_tag($file, FALSE);
return $this;
}
// --------------------------------------------------------------------------
/**
* Sets html title string
* @param string $title
* @return Page
*/
public function set_title($title="")
{
$title = ($title == "") ?
$this->CI->config->item('default_title') : $title;
$this->title = $title;
return $this;
}
// --------------------------------------------------------------------------
/**
* Sets custom body id
* @param string $id
* @return Page
*/
public function set_body_id($page_id="")
{
$this->body_id = $page_id;
return $this;
}
// --------------------------------------------------------------------------
/**
* Sets custom page header
* @return $this
*/
public function build_header()
{
$data = array();
//Set Meta Tags
$this->meta = T1.'<meta charset="utf-8" />'.NL. $this->meta;
$data['meta'] = $this->meta;
//Set CSS
if ($this->css != "")
{
$data['css'] = $this->css;
}
else
{
//Set default CSS group
$this->set_css_group($this->CI->config->item('default_css_group'));
$data['css'] = $this->css;
}
//Set head javascript
$data['head_js'] = ( ! empty($this->head_js)) ? $this->head_js : "";
//Set Page Title
$data['title'] = ( ! empty($this->title)) ? $this->title : $this->CI->config->item('default_title');
//Set Body Id
$data['body_id'] = $this->body_id;
//Set Server Headers and Doctype
$this->_headers();
//Output Header
$this->CI->load->view('header', $data);
return $this;
}
// --------------------------------------------------------------------------
/**
* Shortcut method to cut down on boilerplate
*
* @param string $view
* @param array|object $data
* @return void
*/
public function build($view, $data = array())
{
$this->build_header();
$this->CI->load->view($view, $data);
$this->build_footer();
}
// --------------------------------------------------------------------------
/**
* Builds common footer with any additional js
*/
public function build_footer()
{
$data = array();
$data['foot_js'] = ($this->foot_js != "") ?
$this->foot_js : '';
$this->CI->load->view('footer', $data);
}
// --------------------------------------------------------------------------
/**
* Script Tag
*
* Helper function for making script tags
*
* @param string $js
* @param bool $domain
* @return string
*/
private function script_tag($javascript, $domain=TRUE)
{
$path = $this->CI->config->item('content_domain');
$js_file = $path . "/js/" . $javascript . ".js";
if ($domain == FALSE)
$js_file = $javascript;
$tag = '<script src="' .
$js_file .
'"></script>'.NL;
return $tag;
}
// --------------------------------------------------------------------------
/**
* Num Queries
*
* Returns number of queries run on a page
*
* @return int
*/
public function num_queries()
{
return (isset($this->CI->db)) ? count($this->CI->db->queries) : 0;
}
// --------------------------------------------------------------------------
/**
* Set Message
*
* Adds a message to the page
* @param string $type
* @param string $message
* @param bool $return
* @return mixed
*/
public function set_message($type, $message, $return = FALSE)
{
$data['stat_type'] = $type;
$data['message'] = $message;
return $this->CI->load->view('message', $data, $return);
}
}

843
application/libraries/Todo.php Executable file
View File

@ -0,0 +1,843 @@
<?php
/**
* Public Library Todo
*
* Library for general tasks in Todo application
* @package Todo
*/
class Todo {
private $user, $pass, $email, $CI, $uid; //For user registration
/**
* Constructor
*/
public function __construct()
{
$this->CI =& get_instance();
}
// --------------------------------------------------------------------------
/**
* Get User From Id
*
* Retrieve a user's username from their userid
* @param int $user_id
* @return string
*/
public function get_user_from_id($user_id)
{
$this->CI->db->select('id, username')
->from('todo_user')
->where('id', (int) $user_id);
$res = $this->CI->db->get();
$row = $res->row();
return $row->username;
}
// --------------------------------------------------------------------------
/**
* Crypt Pass
*
* Hashes passwords
* @param string $password
* @return string
*/
public function crypt_pass($password)
{
return password_hash($password, PASSWORD_BCRYPT);
}
// --------------------------------------------------------------------------
/**
* Add Reg
*
* Submits a new user to the database
* @return integer
*/
public function add_reg()
{
$user = $this->CI->input->post('user', TRUE);
$pass = $this->crypt_pass($this->CI->input->post('pass', TRUE));
$email = $this->CI->input->post('email', TRUE);
$this->CI->db->set('username', $user)
->set('password', $pass)
->set('email', $email);
$this->CI->db->insert('user');
//Get affected rows
$affected_rows = $this->CI->db->affected_rows();
//Get the userid of the latest user
$res = $this->CI->db->select('MAX(id) as id')
->from('user')
->get();
$row = $res->row();
$this->uid = $row->id;
//Add a group with the same name as the user
$this->CI->db->set('name', $user)
->insert('group');
//Get the groupid of the latest group
$res2 = $this->CI->db->select('MAX(id) as id')
->from('group')
->get();
$row = $res2->row();
$g_id = $row->id;
//Set that user as the admin of that group
$this->CI->db->set('group_id', $g_id)
->set('user_id', $this->uid)
->set('is_admin', 1)
->insert('group_users_link');
//Return affected rows
return $affected_rows;
}
// --------------------------------------------------------------------------
/**
* Get Categories
*
* Retrieves list of category types from the database
* @return array
*/
public function get_category_list()
{
$user_group_id = $this->get_user_group();
$cat = $this->CI->db->select('id,title,description,group_id')
->from('category')
->where('group_id', $user_group_id)
->or_where('group_id', 0)
->order_by('group_id', 'desc')
->order_by('title', 'asc')
->get();
return $cat->result_array();
}
// --------------------------------------------------------------------------
/**
* Get Group List
*
* An alias for the private get_groups method
* @param int
* @return array
*/
public function get_group_list($user_id)
{
return $this->get_groups($user_id);
}
// --------------------------------------------------------------------------
/**
* Add Category
*
* Submits a new category to the database
* @return bool
*/
public function add_category()
{
if($this->CI->input->post('title') == FALSE || $this->CI->input->post('desc') == FALSE)
{
show_error('You must put a title and description!');
return false;
}
$title = $this->CI->input->post('title', TRUE);
$desc = $this->CI->input->post('desc', TRUE);
//Check for the current category
$this->CI->db->select('title')
->from('category')
->where('title', $title);
$res = $this->CI->db->get();
if($res->num_rows() == 0)
{
//Get the current user's primary group
$group_id = $this->get_user_group();
//print_r($group_id);
$this->CI->db->set('title', $title)
->set('description', $desc)
->set('group_id', $group_id);
//Insert the new record
$this->CI->db->insert('category');
$this->CI->session->flashdata('message', 'Successfully added new category.');
return true;
}
else
{
show_error('This category already exists!');
return false;
}
}
// --------------------------------------------------------------------------
/**
* Add Group
*
* Submits a new group to the database
* @return bool
*/
public function add_group()
{
if($this->CI->input->post('name') == FALSE)
{
show_error('You must have a name for your new group!');
return false;
}
$name = $this->CI->input->post('name');
//Add group
$this->CI->db->set("name", $name)->insert('group');
//Get the groupid of the latest group
$res = $this->CI->db->select('MAX(id) as id')
->from('group')
->get();
$row = $res->row();
$g_id = $row->id;
//Set that user as the admin of that group
$this->CI->db->set('group_id', $g_id)
->set('user_id', $this->CI->session->userdata('uid'))
->set('is_admin', 1)
->insert('group_users_link');
}
// --------------------------------------------------------------------------
/**
* Get Category Select
*
* Generates select options for categories when adding a new task
* @return string
*/
public function get_category_select()
{
$select_array = $this->get_category_list();
$html = '';
foreach($select_array as $r)
{
$html .= T4.'<option value="'.$r['id'].'">' . $r['title'] . '</option>'. "\n";
}
return $html;
}
// --------------------------------------------------------------------------
/**
* Get Priority Select
*
* Generates select options for priorities when adding a new task
* @return string
*/
public function get_priority_select()
{
$select_array = $this->get_priorities();
$html = '';
foreach($select_array as $r)
{
$html .= T4.'<option value="'.$r['id'].'" ';
$html .= ($r['id'] == 5) ? 'selected="selected">': '>';
$html .= $r['value'] . '</option>'. "\n";
}
return $html;
}
// --------------------------------------------------------------------------
/**
* Get Group Select
*
* Generates select options for groups when adding a friend
* @param int $user_id
* @return string
*/
public function get_group_select($user_id)
{
$select_array = $this->get_groups($user_id);
$html = '';
foreach($select_array as $r)
{
$html .= T4.'<option value="'.$r['id'].'">' . $r['name'] . '</option>'. "\n";
}
return $html;
}
// --------------------------------------------------------------------------
/**
* Validate Pass
*
* Validate Password Change
* @return mixed
*/
public function validate_pass()
{
$err = array();
$user = $this->CI->session->userdata('uid');
$pass = $this->CI->input->post('pass');
$pass1 = $this->CI->input->post('pass1');
$old_pass = $this->CI->input->post('old_pass');
if($pass != $pass1)
$err[] = "Passwords do not match.";
//Check for current password in the database
$user_check = $this->CI->db->select('password')
->from('user')
->get();
$row = $user_check->row();
if ( ! password_verify($old_pass, $row->password))
{
$err[] = "Wrong password";
}
$res = (empty($err)) ? true : $err;
if($res == TRUE)
{
$this->user = $user;
$this->pass = $pass;
}
return $res;
}
// --------------------------------------------------------------------------
/**
* Update Pass
*
* Updates user's password in the database
*/
public function update_pass()
{
$pass = $this->crypt_pass($this->pass);
$this->CI->db->set('password', $pass)
->where('id', $this->user)
->update('user');
}
// --------------------------------------------------------------------------
/**
* Redirect 303
*
* Shortcut function for 303 redirect
* @param string $url
*/
public function redirect_303($url)
{
if (stripos($url, 'http') === FALSE)
{
$url = site_url($url);
}
$this->CI->output->set_header("HTTP/1.1 303 See Other");
$this->CI->output->set_header("Location:" . $url);
}
// --------------------------------------------------------------------------
/**
* Set Timezone
*
* Sets the timezone based on the user's settings
* @param int $uid
* @param string $timezone
* @return bool
*/
public function set_timezone($uid, $timezone)
{
$this->db->set('timezone', $timezone)
->where('id', $uid)
->update('user');
return ($this->db->affected_rows == 1);
}
// --------------------------------------------------------------------------
/**
* Get Priorities
*
* Retreives list of priority types from the database
* @return array
*/
public function get_priorities()
{
$pri = $this->CI->db->select('id,value')
->from('priority')
->order_by('id', 'asc')
->get();
return $pri->result_array();
}
// --------------------------------------------------------------------------
/**
* Get Groups
*
* Retrieves user's groups from db
* @param int $user_id
* @return array
*/
private function get_groups($user_id)
{
$username = $this->get_user_from_id($user_id);
$groups = $this->CI->db->select("group.id, name")
->from('group')
->join('group_users_link', 'group.id = group_users_link.group_id', 'inner')
->where('user_id', $user_id)
->where('name !=', $username)
->where('is_admin', 1)
->get();
return $groups->result_array();
}
// --------------------------------------------------------------------------
/**
* Get User Account By Id
*
* Retrieves user's account info from db
* @param int $user_id
* @return array
*/
public function get_user_account_by_id($user_id)
{
$user_account = array();
//Get the user
$user_query = $this->CI->db->from('user')
->where('id', (int) $user_id)
->get();
$user = $user_query->row();
$user_account['timezone'] = $user->timezone;
$user_account['user'] = $user->username;
$user_account['email'] = $user->email;
$user_account['num_format'] = $user->num_format;
return $user_account;
}
// --------------------------------------------------------------------------
/**
* Get User Group
*
* Gets the current user's primary group
* @return int
*/
public function get_user_group()
{
$user_id = $this->CI->session->userdata('uid');
//Get the username
$uname = $this->get_user_from_id($user_id);
$group_query = $this->CI->db->select('group.id as group_id')
->from('group')
->where('name', $uname)
->limit(1)
->get();
$group = $group_query->row();
$group_id = $group->group_id;
return $group_id;
}
// --------------------------------------------------------------------------
/**
* Get Friend List
*
* Gets the friends of the current user
* @return array
*/
public function get_friend_list()
{
$user_id = $this->CI->session->userdata('uid');
//Get the current user's username
$uname = $this->CI->db->select('username')
->from('user')
->where('id', $user_id)
->get();
$user_n = $uname->row();
$username = $user_n->username;
//Get the list of friends
$friends = $this->CI->db
->select('user_friend_id,user_friend_link.user_id as uid,user.username')
->from('todo_user_friend_link')
->join('user', 'user.id=user_friend_link.user_friend_id OR "todo_user"."id"="todo_user_friend_link"."user_id"', 'inner')
->where('confirmed', FRIEND_CONFIRMED)
->where('username !=', $username)
->group_start()
->where_in('todo_user_friend_link.user_id', $user_id)
->or_where_in('todo_user_friend_link.user_friend_id', $user_id)
->group_end()
->order_by('username', 'asc')
->get();
return $friends->result_array();
}
// --------------------------------------------------------------------------
/**
* Get Friends in Group
*
* Returns members of a group
* @param int $group_id
* @return array
*/
public function get_friends_in_group($group_id)
{
$friends = $this->CI->db
->select('user_id')
->from('group_users_link')
->where('group_id', $group_id)
->get();
return $friends->result_array();
}
// --------------------------------------------------------------------------
/**
* Update group
*
* Updates a group's membership
*/
public function update_group()
{
$friends = $this->CI->input->post('friends');
$group_name = $this->CI->input->post('group_name');
$group_id = (int)$this->CI->uri->segment('3');
//Drop members in group except the creator
$this->CI->db->where('group_id', $group_id)
->where('is_admin', 0)
->delete('group_users_link');
//Update the group name
$this->CI->db->set('name', $group_name)
->where('id', $group_id)
->update('group');
foreach ($friends as $friend)
{
//Insert new friends
$this->CI->db->set('group_id', $group_id)
->set('user_id', (int) $friend)
->set('is_admin', 0)
->insert('group_users_link');
}
return 1;
}
// --------------------------------------------------------------------------
/**
* Del group
*
* Deletes a friend group
* @param int $group_id
* @return int
*/
public function del_group($group_id)
{
//Check if the current user is group admin
$is_admin = $this->CI->db->from('group_users_link')
->where('group_id', $group_id)
->where('is_admin', 1)
->get();
//The user is admin
if($is_admin->num_rows() > 0)
{
//Delete the related records
$this->CI->db->where('group_id', $group_id)
->delete('group_users_link');
$this->CI->db->where('group_id', $group_id)
->delete('group_task_link');
//Delete the group
$this->CI->db->where('id', $group_id)
->delete('group');
return 1;
}
else
{
return -1;
}
}
// --------------------------------------------------------------------------
/**
* Del Cat
*
* Deletes a task category
* @param int $cat_id
* @return int
*/
public function del_cat($cat_id)
{
//Get the user group id
$gid = $this->get_user_group();
//Delete the category that matches the cat_id and gid
$this->CI->db->where('group_id', $gid)
->where('id', $cat_id)
->delete('category');
if($this->CI->db->affected_rows() > 0)
{
return $this->CI->db->affected_rows();
}
else
{
return -1;
}
}
// --------------------------------------------------------------------------
/**
* Get group name by id
*
* Gets a group name from the group id
* @param int $group_id
* @return string
*/
public function get_group_name_by_id($group_id)
{
$query = $this->CI->db->select('name')
->from('group')
->where('id', $group_id)
->get();
$qrow = $query->row();
$name = $qrow->name;
return $name;
}
// --------------------------------------------------------------------------
/**
* Kanji Num
*
* Converts arabic to chinese number
* @param int $number
* @return string
*/
public function kanji_num($orig_number)
{
$kanji_num = '';
$number = (int) $orig_number;
// Return early on a zero
if ($number === 0) return ZERO;
// Map variables to their values and characters
$meta_map = [
100000000 => HUNDRED_MILLION,
10000 => TEN_THOUSAND,
1000 => THOUSAND,
100 => HUNDRED,
10 => TEN
];
// Map values to their kanji equivalent
$char_map = [
1 => ONE,
2 => TWO,
3 => THREE,
4 => FOUR,
5 => FIVE,
6 => SIX,
7 => SEVEN,
8 => EIGHT,
9 => NINE,
];
// Go through each place value
// to get the kanji equivalent of
foreach($meta_map as $value => $char)
{
if ($number < $value) continue;
// Calculate the place value variable
$place_value = floor($number / $value);
// Get the remainder for the next place value;
$number = $number - ($place_value * $value);
// Recurse if the number is between 11,000
// and 100,000,000 to get the proper prefix,
// which can be up to 9,999
if ($orig_number > 10000 && $place_value > 9)
{
$kanji_num .= $this->kanji_num($place_value);
$place_value = 1;
}
// Add place value character and
// place value to the output string,
// skipping zero and one. A zero value
// hides the place value character, and one
// value is implied if there is no value
// prefixing the place value character
$kanji_num .= ($place_value > 1)
? $char_map[$place_value] . $char
: $char;
}
// Add the smallest place value last, as a
// one value is significant here
$kanji_num .= ($number > 0) ? $char_map[$number] : '';
return $kanji_num;
}
// --------------------------------------------------------------------------
/**
* Get Category
*
* Returns a category from id
* @param int $cat_id
* @return array
*/
public function get_category($cat_id)
{
$cats = $this->CI->db->select('title, description')
->from('category')
->where('id', $cat_id)
->limit('1')
->get();
$cat = $cats->row_array();
return $cat;
}
// --------------------------------------------------------------------------
/**
* Get Friend Requests
*
* Retrieves number of friend requests for the current user
* @return int
*/
public function get_friend_requests()
{
static $requests = NULL;
if (is_null($requests))
{
//Get friend requests for the current user
$requests = $this->CI->db->select('user_id')
->distinct()
->from('user_friend_link')
->where('user_friend_id', $this->CI->session->userdata('uid'))
->where('confirmed', -1)
->get()
->num_rows();
}
return $requests;
}
/**
* Authenticate the user
*
* @return string
*/
public function verify_user()
{
$user = $this->CI->input->post('user');
$pass = $this->CI->input->post('pass');
//Check for the user in the database
$uid_check = $this->CI->db->select('id, username, email, password, timezone, num_format')
->from('user')
->group_start()
->where('email', $user)
->or_where('username', $user)
->group_end()
->get();
$row = $uid_check->row();
if (password_verify($pass, $row->password))
{
$this->CI->session->set_userdata('uid', $row->id);
$this->CI->session->set_userdata('num_format', $row->num_format);
$this->CI->session->set_userdata('username', $row->username);
//Set Timezone
$zone = $row->timezone;
$tz_set = date_default_timezone_set($zone);
if($tz_set == FALSE) display_error('Could not set timezone');
//Redirect to task list
return TRUE;
}
else
{
return "Invalid username or password";
}
}
}
// End of libraries/Todo.php

View File

@ -0,0 +1,61 @@
<?php
/**
* Form validation callbacks
*/
class Validation_callbacks {
/**
* CodeIgniter Instance
*
* @var MY_Controller
*/
protected $CI;
/**
* Constructor
*/
public function __construct()
{
$this->CI =& get_instance();
}
/**
* Validate the format of the due date field
*
* @param string $due
* @return bool
*/
public function due_date($due)
{
//Verify date format
$date_pattern = '/(20|1[0-9])[0-9]{2}\-(1[0-2]|0[1-9])\-(3[0-1]|2[0-8]|1[0-9]|0[1-9])/';
if ( ! (bool) preg_match($date_pattern, $due))
{
$this->CI->form_validation->set_message('validate', 'You must enter a due date in YYYY-MM-DD format.');
return FALSE;
}
return TRUE;
}
/**
* Verify that an email address is valid
*
* @param string $email
* @return bool
*/
public function valid_email($email)
{
$valid = filter_var($email, FILTER_VALIDATE_EMAIL);
if ( ! $valid)
{
$this->CI->form_validation->set_message('validate', 'You must enter a valid email address.');
}
return $valid;
}
}
// End of libraries/Validation_callbacks.php

10
application/logs/index.html Executable file
View File

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@ -0,0 +1,283 @@
<?php
/**
* Model for friend management
*/
class Friend_model extends CI_Model {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
}
// --------------------------------------------------------------------------
/**
* Get Friends
*
* Gets list of friends and their associated groups
* @return mixed
*/
public function get_friends()
{
$user_id = $this->session->userdata('uid');
//Get the list of friends
$friends = $this->db
->select('user_friend_id,user_friend_link.user_id as uid,user.username,user.email')
->from('todo_user_friend_link')
->join('user', 'user.id=user_friend_link.user_friend_id OR "todo_user"."id"="todo_user_friend_link"."user_id"', 'inner')
->group_start()
->where_in('todo_user_friend_link.user_id', $user_id)
->or_where_in('todo_user_friend_link.user_friend_id', $user_id)
->group_end()
->where('confirmed', FRIEND_CONFIRMED)
->where('user.id !=', $user_id)
->order_by('username', 'asc')
->get();
if($friends->num_rows() > 0) //Retrieve friends
{
$res_array = array();
$friend_list = array();
foreach ($friends->result_array() as $friend)
{
$friend_id = ($friend['uid'] !== $user_id)
? $friend['uid']
: $friend['user_friend_id'];
$res_array[$friend_id] = $friend;
$friend_list[] = $friend_id;
}
//Get each user's groups
$groups = $this->db->select('user_id, name as group_name')
->distinct()
->from('group')
->join('group_users_link', 'group_users_link.group_id=group.id', 'inner')
->where_in('todo_group_users_link.user_id', $friend_list)
->order_by('user_id, group_name', 'asc')
->get();
if($groups->num_rows() > 0)
{
foreach($groups->result_array() as $group)
{
$res_array[$group['user_id']]['groups'][] = $group['group_name'];
}
}
return $res_array;
}
else
{
return FALSE;
}
}
// --------------------------------------------------------------------------
/**
* Find Friends
*
* Gets list of possible friends from search query
* @return mixed
*/
public function find_friends()
{
$query = $this->input->get('q', TRUE);
$user_id = (int) $this->session->userdata('uid');
// Don't allow empty searches to reach the database
if (empty($query)) return [];
//Loosely match usernames and emails to query
$res = $this->db->select('id, username, email')
->from('user')
->like('username', $query, 'after')
->or_like('email', $query, 'after')
->order_by('username', 'asc')
->get();
if($res->num_rows() > 0)
{
$return = array();
foreach($res->result_array() as $friend)
{
//This person is already a friend
if($this->_check_friend($friend['id']) == TRUE)
continue;
//If the person is you :/
if($user_id == $friend['id'])
continue;
$return[] = $friend;
}
return $return;
}
return (isset($return)) ? $return : [];
}
// --------------------------------------------------------------------------
/**
* Get Request
*
* Gets friend requests to the current user
* @return mixed
*/
public function get_requests()
{
$user_id = $this->session->userdata('uid');
//Get the list of requests
$requests = $this->db->select('user_id, username, email')
->from('user_friend_link')
->where('user_friend_id', $user_id)
->where('confirmed', -1)
->join('user', 'user.id=user_friend_link.user_id')
->get();
if($requests->num_rows() > 0)
{
return $requests->result_array();
}
else
{
return false;
}
}
// --------------------------------------------------------------------------
/**
* Send Request
*
* Sends a friend request, or confirms a mutual friend request
*
* @param int $friend_id
* @return int
*/
public function send_request($friend_id)
{
$user_id = (int) $this->session->userdata('uid');
//Check for request from the user
$friend_check = $this->db->select('user_id')
->from('user_friend_link')
->where('user_id', $friend_id)
->where('user_friend_id', $user_id)
->get();
if($friend_check->num_rows() > 0)
{
// Accept the friend request
// Allows the user to add a friend they ignored
// in their requests
$this->db->set('confirmed', FRIEND_CONFIRMED)
->where('user_id', $friend_id)
->where('user_friend_id', $user_id)
->where('confirmed', FRIEND_NOT_CONFIRMED)
->update('user_friend_link');
}
else
{
//Check if the request already exists
$request_check = $this->db->from('user_friend_link')
->where('user_friend_id', $friend_id)
->where('user_id', $user_id)
->get();
if($request_check->num_rows() > 0) return -1;
//Add a friend request only if it doesn't already exist
$this->db->set('user_id', $user_id)
->set('user_friend_id', $friend_id)
->insert('user_friend_link');
}
return $this->db->affected_rows();
}
// --------------------------------------------------------------------------
/**
* Accept Request
*
* Accept a friend request
* @param int $request_id
* @return int
*/
public function accept_request($request_id)
{
$this->db->set('confirmed', FRIEND_CONFIRMED)
->where('user_id', (int)$request_id)
->where('confirmed', FRIEND_NOT_CONFIRMED)
->update('user_friend_link');
return $this->db->affected_rows();
}
// --------------------------------------------------------------------------
/**
* Reject Request
*
* Reject a friend request
* @param int $request_id
* @return int
*/
public function reject_request($request_id)
{
$this->db->set('confirmed', FRIEND_REJECTED)
->where('user_id', (int)$request_id)
->where('confirmed', FRIEND_NOT_CONFIRMED)
->update('user_friend_link');
return $this->db->affected_rows();
}
// --------------------------------------------------------------------------
/**
* Check Friend
*
* Check if a user is already a friend
* @param int $friend_id
* @return bool
*/
public function _check_friend($friend_id)
{
$user_id = $this->session->userdata('uid');
if($user_id == $friend_id)
return FALSE;
$friend = $this->db->select('user_id, user_friend_id')
->from('user_friend_link')
->where('user_id', $user_id)
->where('user_friend_id', $friend_id)
->where('confirmed', FRIEND_CONFIRMED)
->or_where('user_id', $friend_id)
->where('user_friend_id', $user_id)
->where('confirmed', FRIEND_CONFIRMED)
->get();
return (bool)($friend->num_rows() > 0);
}
}
// End of models/friend_model.php

147
application/models/mail_model.php Executable file
View File

@ -0,0 +1,147 @@
<?php
/**
* Public Model Mail_Model
* @package Todo
*/
class Mail_model extends CI_Model {
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('email');
//Set email config
$config = array(
'useragent' => "Tim's Todo",
'protocol' => 'mail',
'mailtype' => 'text',
'charset' => 'utf-8',
'validate' => 'true',
'priority' => '3',
);
$this->email->initialize($config);
}
// --------------------------------------------------------------------------
/**
* Check what reminders need to be sent out for the current run
*
* @return mixed
*/
public function check_db()
{
//Get the current time
$now = time();
//Get two minuts from now
$interval_new = $now + 900;
//Get reminders within two minutes of now, that have not been sent
$this->db->select('reminder.id as rem_id, todo_item.id as task_num,
reminder_time, due, sent, title, email, username')
->from('reminder')
->join('item', 'todo_item.id = todo_reminder.task_id', 'inner')
->join('user', 'todo_user.id = todo_reminder.user_id', 'inner')
->where('reminder_time <', $interval_new)
->where('sent', 0);
$query = $this->db->get();
//If no results, return
if($query->num_rows() == 0)
return;
//Format, then send the email
$this->_format_email($query);
//Return debugging info
$return = $this->email->print_debugger();
//Log debugging info
log_message('debug', $return);
//Clear the email object for the next loop
$this->email->clear();
return $return;
}
// --------------------------------------------------------------------------
/**
* Format the email to send for a reminder
*
* @param $query
*/
private function _format_email($query)
{
foreach($query->result() as $row)
{
$due = $row->due;
$due_reminder = $row->reminder_time;
//Time until task is due, in seconds
$until_due = $due - $due_reminder;
//In hours
$until_hours = ($until_due >= 3600) ? floor((int)$until_due / 3600) : 0;
//In additional minutes
$um = (int)$until_due - ($until_hours * 3600);
$until_minutes = (int)($um / 60);
$user = $row->username;
$task_num = $row->task_num;
$task = $row->title;
$to = $row->email;
$rem_id = $row->rem_id;
$due_time = date('D M d, Y g:iA T', $due);
$subject = "Tim's Todo Reminder: '" . $task . "' is due soon";
$message = $user . ",\r\n".
"This is a reminder that task #". $task_num .", '".$task."' is due in ".
$until_hours." hours and ".$until_minutes." minutes, at " . $due_time;
//Set email parameters
$this->email->to($to);
$this->email->from('noreply@timshomepage.net', "Tim's Todo");
$this->email->message($message);
$this->email->subject($subject);
$this->_send($rem_id);
}
}
// --------------------------------------------------------------------------
/**
* Send a reminder, and mark the reminder as sent
*
* @param $rem_id
*/
private function _send($rem_id)
{
$result = $this->email->send();
echo (int) $result . "\n";
if($result != FALSE)
{
//Set as set in the database
$this->db->set('sent', 1)
->where('id', $rem_id)
->update('reminder');
}
}
}
// End of models/mail_model.php

1597
application/models/task_model.php Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,278 @@
<?php
/*
echo '<pre>';
var_dump($GLOBALS);
echo '</pre>';
exit;
*/
/*
* ------------------------------------------------------
* CIUnit Version
* ------------------------------------------------------
*/
define('CIUnit_Version', '0.18-dev_for_CI2.1.0');
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'testing');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* By default CI runs with error reporting set to -1.
*
*/
error_reporting(-1);
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same directory
* as this file.
*
* NO TRAILING SLASH!
*
* The test should be run from inside the tests folder. The assumption
* is that the tests folder is in the same directory path as system. If
* it is not, update the paths appropriately.
*/
$system_path = dirname(__FILE__) . '/../../../system';
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*
* The tests should be run from inside the tests folder. The assumption
* is that the tests folder is in the same directory as the application
* folder. If it is not, update the path accordingly.
*/
$application_folder = dirname(__FILE__) . '/../..';
/*
*---------------------------------------------------------------
* VIEW FOLDER NAME
*---------------------------------------------------------------
*
* If you want to move the view folder out of the application
* folder set the path to the folder here. The folder can be renamed
* and relocated anywhere on your server. If blank, it will default
* to the standard location inside your application folder. If you
* do move this, use the full server path to this folder
*
* NO TRAILING SLASH!
*
*/
$view_folder = '';
/*
* -------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* -------------------------------------------------------------------
*
* The $assign_to_config array below will be passed dynamically to the
* config class when initialized. This allows you to set custom config
* items or override any default config values found in the config.php file.
* This can be handy as it permits you to share one application between
* multiple front controller files, with each file containing different
* config values.
*
* Un-comment the $assign_to_config array below to use this feature
*
*/
// $assign_to_config['name_of_config_item'] = 'value of config item';
/**
* --------------------------------------------------------------
* CIUNIT FOLDER NAME
* --------------------------------------------------------------
*
* Typically this folder will be within the application's third-party
* folder. However, you can place the folder in any directory. Just
* be sure to update this path.
*
* NO TRAILING SLASH!
*
*/
$ciunit_folder = dirname(__FILE__);
/**
* --------------------------------------------------------------
* UNIT TESTS FOLDER NAME
* --------------------------------------------------------------
*
* This is the path to the tests folder.
*/
$tests_folder = dirname(__FILE__) . "/../../../tests";
// --------------------------------------------------------------------
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/
/* This chdir() causes error when run tests by folder.
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
*/
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
/*
* -------------------------------------------------------------------
* Now that we know the path, set the main path constants
* -------------------------------------------------------------------
*/
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// The PHP file extension
// this global constant is deprecated.
define('EXT', '.php');
// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));
// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));
// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
// The path to the "application" folder
if (is_dir($application_folder))
{
define('APPPATH', realpath($application_folder) . '/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define('APPPATH', realpath(BASEPATH.$application_folder) . '/');
}
// The path to the "views" folder
if (is_dir($view_folder))
{
define ('VIEWPATH', $view_folder .'/');
}
else
{
if ( ! is_dir(APPPATH.'views/'))
{
exit("Your view folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define ('VIEWPATH', APPPATH.'views/' );
}
// The path to CIUnit
if (is_dir($ciunit_folder))
{
define('CIUPATH', $ciunit_folder . '/');
}
else
{
if ( ! is_dir(APPPATH . 'third_party/' . $ciunit_folder))
{
exit("Your CIUnit folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define ('CIUPATH', APPPATH . 'third_party/' . $ciunit_folder);
}
// The path to the Tests folder
define('TESTSPATH', realpath($tests_folder) . '/');
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*
*/
// Load the CIUnit CodeIgniter Core
require_once CIUPATH . 'core/CodeIgniter.php';
// Autoload the PHPUnit Framework
//require_once ('PHPUnit/Autoload.php');
// Load the CIUnit Framework
require_once CIUPATH. 'libraries/CIUnit.php';
//=== and off we go ===
$CI =& set_controller('CIU_Controller', CIUPATH . 'core/');
$CI->load->add_package_path(CIUPATH);
require_once(CIUPATH . 'libraries/spyc/spyc.php');
CIUnit::$spyc = new Spyc();
require_once(CIUPATH . 'libraries/Fixture.php');
$CI->fixture = new Fixture();
CIUnit::$fixture =& $CI->fixture;
/* End of file bootstrap_phpunit.php */
/* Location: ./application/third_party/CIUnit/bootstrap_phpunit.php */

View File

@ -0,0 +1,13 @@
<?php
/*
* fooStack, CIUnit for CodeIgniter
* Copyright (c) 2008-2009 Clemens Gruenberger
* Released under the MIT license, see:
* http://www.opensource.org/licenses/mit-license.php
*/
$config['ciu_subclass_prefix'] = 'CIU_';
/* End of file config.php */
/* Location ./application/third_party/CIUnit/config/config.php */

View File

@ -0,0 +1,23 @@
<?php
if (! defined('BASEPATH')) {
exit('No direct script access');
}
class CIU_Controller extends MY_Controller {
public function __construct()
{
parent::__construct();
$this->load->database('test');
}
public function index()
{
return;
}
}
/* End of file CIU_Controller.php */
/* Location: ./application/third_party/CIUnit/core/CIU_Controller.php */

View File

@ -0,0 +1,137 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Exceptions Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Exceptions
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/exceptions.html
*/
class CIU_Exceptions extends CI_Exceptions {
/**
* Exception Logger
*
* This function logs PHP generated error messages
*
* @access private
* @param string the error severity
* @param string the error string
* @param string the error filepath
* @param string the error line number
* @return string
*/
function log_exception($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
}
// --------------------------------------------------------------------
/**
* 404 Page Not Found Handler
*
* @access private
* @param string
* @return string
*/
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
log_message('error', '404 Page Not Found --> '.$page);
}
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
// --------------------------------------------------------------------
/**
* General Error Page
*
* This function takes an error message as input
* (either as a string or an array) and displays
* it using the specified template.
*
* @access private
* @param string the heading
* @param string the message
* @param string the template name
* @return string
*/
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
$message = implode(' ', ( ! is_array($message)) ? array($message) : $message);
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
echo "[CIUnit] Error: $status_code Message: $message\n";
return;
}
// --------------------------------------------------------------------
/**
* Native PHP error handler
*
* @access private
* @param string the error severity
* @param string the error string
* @param string the error filepath
* @param string the error line number
* @return string
*/
function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace("\\", "/", $filepath);
// For safety reasons we do not show the full file path
if (FALSE !== strpos($filepath, '/'))
{
$x = explode('/', $filepath);
$filepath = $x[count($x)-2].'/'.end($x);
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
echo "[CIUnit] PHP Error: $severity - $message File Path: $filepath (line: $line)\n";
}
}
/* End of file CIU_Exceptions.php */
/* Location: ./application/third_party/CIUnit/core/CIU_Exceptions.php */

View File

@ -0,0 +1,437 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* fooStack, CIUnit for CodeIgniter
* Copyright (c) 2008-2009 Clemens Gruenberger
* Released under the MIT license, see:
* http://www.opensource.org/licenses/mit-license.php
*/
/*
* CodeIgniter source modified for fooStack / CIUnit
*
* If you use MY_Loader, change the paraent class.
*/
class CIU_Loader extends CI_Loader {
/**
* Load class
*
* This function loads the requested class.
*
* @param string the item that is being loaded
* @param mixed any additional parameters
* @param string an optional object name
* @return void
*/
protected function _ci_load_class($class, $params = NULL, $object_name = NULL)
{
// Get the class name, and while we're at it trim any slashes.
// The directory path can be included as part of the class name,
// but we don't want a leading slash
$class = str_replace('.php', '', trim($class, '/'));
// Was the path included with the class name?
// We look for a slash to determine this
$subdir = '';
if (($last_slash = strrpos($class, '/')) !== FALSE)
{
// Extract the path
$subdir = substr($class, 0, $last_slash + 1);
// Get the filename from the path
$class = substr($class, $last_slash + 1);
}
// We'll test for both lowercase and capitalized versions of the file name
foreach (array(ucfirst($class), strtolower($class)) as $class)
{
$subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php';
$ciu_subclass = CIUPATH.'libraries/'.$subdir.config_item('ciu_subclass_prefix').$class.'.php';
// Is this a class extension request?
if (file_exists($ciu_subclass))
{
$baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php';
if ( ! file_exists($baseclass))
{
log_message('error', "Unable to load the requested class: ".$class);
show_error("Unable to load the requested class: ".$class);
}
// Safety: Was the class already loaded by a previous call?
if (in_array($ciu_subclass, $this->_ci_loaded_files))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ( ! is_null($object_name))
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_class($class, config_item('ciu_subclass_prefix'), $params, $object_name);
}
}
$is_duplicate = TRUE;
log_message('debug', $class." class already loaded. Second attempt ignored.");
return;
}
include_once($baseclass);
if (file_exists($subclass))
{
include_once($subclass);
}
include_once($ciu_subclass);
$this->_ci_loaded_files[] = $ciu_subclass;
return $this->_ci_init_class($class, config_item('ciu_subclass_prefix'), $params, $object_name);
}
// Is this a class extension request?
if (file_exists($subclass))
{
$baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php';
if ( ! file_exists($baseclass))
{
log_message('error', "Unable to load the requested class: ".$class);
show_error("Unable to load the requested class: ".$class);
}
// Safety: Was the class already loaded by a previous call?
if (in_array($subclass, $this->_ci_loaded_files))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ( ! is_null($object_name))
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
}
}
$is_duplicate = TRUE;
log_message('debug', $class." class already loaded. Second attempt ignored.");
return;
}
include_once($baseclass);
include_once($subclass);
$this->_ci_loaded_files[] = $subclass;
return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name);
}
// Lets search for the requested library file and load it.
$is_duplicate = FALSE;
foreach ($this->_ci_library_paths as $path)
{
$filepath = $path.'libraries/'.$subdir.$class.'.php';
// Does the file exist? No? Bummer...
if ( ! file_exists($filepath))
{
continue;
}
// Safety: Was the class already loaded by a previous call?
if (in_array($filepath, $this->_ci_loaded_files))
{
// Before we deem this to be a duplicate request, let's see
// if a custom object name is being supplied. If so, we'll
// return a new instance of the object
if ( ! is_null($object_name))
{
$CI =& get_instance();
if ( ! isset($CI->$object_name))
{
return $this->_ci_init_class($class, '', $params, $object_name);
}
}
$is_duplicate = TRUE;
log_message('debug', $class." class already loaded. Second attempt ignored.");
return;
}
include_once($filepath);
$this->_ci_loaded_files[] = $filepath;
return $this->_ci_init_class($class, '', $params, $object_name);
}
} // END FOREACH
// One last attempt. Maybe the library is in a subdirectory, but it wasn't specified?
if ($subdir == '')
{
$path = strtolower($class).'/'.$class;
return $this->_ci_load_class($path, $params);
}
// If we got this far we were unable to find the requested class.
// We do not issue errors if the load call failed due to a duplicate request
if ($is_duplicate == FALSE)
{
log_message('error', "Unable to load the requested class: ".$class);
show_error("Unable to load the requested class: ".$class);
}
}
// --------------------------------------------------------------------
/**
* Instantiates a class
*
* @param string
* @param string
* @param string an optional object name
* @return null
*/
protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
{
// Is there an associated config file for this class? Note: these should always be lowercase
if ($config === NULL)
{
// Fetch the config paths containing any package paths
$config_component = $this->_ci_get_component('config');
if (is_array($config_component->_config_paths))
{
// Break on the first found file, thus package files
// are not overridden by default paths
foreach ($config_component->_config_paths as $path)
{
// We test for both uppercase and lowercase, for servers that
// are case-sensitive with regard to file names. Check for environment
// first, global next
if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
{
include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
break;
}
elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
{
include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
break;
}
elseif (file_exists($path .'config/'.strtolower($class).'.php'))
{
include($path .'config/'.strtolower($class).'.php');
break;
}
elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php'))
{
include($path .'config/'.ucfirst(strtolower($class)).'.php');
break;
}
}
}
}
if ($prefix == '')
{
if (class_exists('CI_'.$class))
{
$name = 'CI_'.$class;
}
elseif (class_exists(config_item('subclass_prefix').$class))
{
$name = config_item('subclass_prefix').$class;
}
else
{
$name = $class;
}
}
else
{
$name = $prefix.$class;
}
// Is the class name valid?
if ( ! class_exists($name))
{
log_message('error', "Non-existent class: ".$name);
show_error("Non-existent class: ".$class);
}
// Set the variable name we will assign the class to
// Was a custom class name supplied? If so we'll use it
$class = strtolower($class);
if (is_null($object_name))
{
$classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class];
}
else
{
$classvar = $object_name;
}
// Save the class name and object name
$this->_ci_classes[$class] = $classvar;
// Instantiate the class
$CI =& get_instance();
if ($config !== NULL)
{
if ( ! defined('CIUnit_Version'))
{
$CI->$classvar = new $name($config);
}
elseif ( ! isset($CI->$classvar))
{
//redesignme: check if we have got one already..
$CI->$classvar = new $name($config);
}
}
else
{
if ( ! defined('CIUnit_Version'))
{
$CI->$classvar = new $name;
}
elseif ( ! isset($CI->$classvar))
{
//redesignme: check if we have got one already..
$CI->$classvar = new $name;
}
}
}
// --------------------------------------------------------------------
/**
* Load View
*
* This function is used to load a "view" file. It has three parameters:
*
* 1. The name of the "view" file to be included.
* 2. An associative array of data to be extracted for use in the view.
* 3. TRUE/FALSE - whether to return the data or load it. In
* some cases it's advantageous to be able to return data so that
* a developer can process it in some way.
*
* @param string
* @param array
* @param bool
* @return void
*/
public function view($view, $vars = array(), $return = FALSE)
{
if ($return === TRUE)
{
return parent::view($view, $vars, $return);
}
$output = $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => TRUE));
$CI =& get_instance();
$CI->output->add_output($output);
}
// --------------------------------------------------------------------
/**
* Load Helper
*
* This function loads the specified helper file.
*
* @param mixed
* @return void
*/
public function helper($helpers = array())
{
foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper)
{
if (isset($this->_ci_helpers[$helper]))
{
continue;
}
$ciu_helper = CIUPATH.'helpers/'.config_item('ciu_subclass_prefix').$helper.'.php';
if (file_exists($ciu_helper))
{
include_once($ciu_helper);
}
$ext_helper = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php';
// Is this a helper extension request?
if (file_exists($ext_helper))
{
$base_helper = BASEPATH.'helpers/'.$helper.'.php';
if ( ! file_exists($base_helper))
{
show_error('Unable to load the requested file: helpers/'.$helper.'.php');
}
include_once($ext_helper);
include_once($base_helper);
$this->_ci_helpers[$helper] = TRUE;
log_message('debug', 'Helper loaded: '.$helper);
continue;
}
// Try to load the helper
foreach ($this->_ci_helper_paths as $path)
{
if (file_exists($path.'helpers/'.$helper.'.php'))
{
include_once($path.'helpers/'.$helper.'.php');
$this->_ci_helpers[$helper] = TRUE;
log_message('debug', 'Helper loaded: '.$helper);
break;
}
}
// unable to load the helper
if ( ! isset($this->_ci_helpers[$helper]))
{
show_error('Unable to load the requested file: helpers/'.$helper.'.php');
}
}
}
// --------------------------------------------------------------------
/*
* Can load a view file from an absolute path and
* relative to the CodeIgniter index.php file
* Handy if you have views outside the usual CI views dir
*/
function viewfile($viewfile, $vars = array(), $return = FALSE)
{
return $this->_ci_load(
array('_ci_path' => $viewfile,
'_ci_vars' => $this->_ci_object_to_array($vars),
'_ci_return' => $return)
);
}
// --------------------------------------------------------------------
function reset()
{
$this->_ci_cached_vars = array();
$this->_ci_classes = array();
$this->_ci_loaded_files = array();
$this->_ci_models = array();
$this->_ci_helpers = array();
}
}
/* End of file CIU_Loader.php */
/* Location: ./application/third_party/CIUnit/core/CIU_Loader.php */

View File

@ -0,0 +1,290 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* fooStack, CIUnit for CodeIgniter
* Copyright (c) 2008-2009 Clemens Gruenberger
* Released under the MIT license, see:
* http://www.opensource.org/licenses/mit-license.php
*/
/*
* CodeIgniter source modified for fooStack / CIUnit
*
* If you use MY_Output, change the paraent class.
*/
class CIU_Output extends CI_Output {
function __construct()
{
parent::__construct();
$this->final_output = ''; //would be just set to 'null' in CI_Output
$this->_ci_ob_level = ob_get_level();
$this->cookies = array();
}
/**
* store cookie headers
*/
function set_cookie($arr)
{
if ( ! is_array($arr))
{
$arr = func_get_args();
}
$this->cookies[] = $arr;
}
/**
* Add to instead of replace final output
*/
function add_output($str)
{
$this->final_output .= $str;
}
/**
* Pop Output
*
* The final output the output class has stringed together is returned and truncated
*
*/
function pop_output()
{
$output = $this->final_output;
$this->final_output = "";
return $output;
}
/**
* set_no_cache_headers
* called as a post controller construction hook
* should count therefore as controller duty
*/
function set_no_cache_headers()
{
//somehow $this can't be used as headers are not set in that case
$CI =& get_instance();
$CI->output->soft_set_header('Content-type: text/html; charset=utf-8');
$CI->output->soft_set_header('Cache-Control: no-cache');
log_message('debug', 'no cache headers set in output class');
}
// --------------------------------------------------------------------
/**
* sets headers if not already set
*/
function soft_set_header($header)
{
$key = strtolower(array_shift(split(':', $header)));
$add = true;
foreach($this->headers as $hdr)
{
$h = split(':', $hdr);
if(strtolower(array_shift($h)) == $key)
{
$add = false;
}
}
$add ? ($this->headers[] = $header) : '';
}
/**
* get headers
*/
function get_headers()
{
return $this->headers;
}
/**
* say
* like normal echo but puts it in the output_buffer first, so we still can set headers
* and post process it
*/
function say($str)
{
ob_start();
echo $str;
$this->ob_flush_clean();
}
/**
* ob_flush_clean
* flushes or cleans the buffer depending on if we are finished outputting or still on a nested level
*/
function ob_flush_clean()
{
$CI =& get_instance();
if (ob_get_level() > $this->_ci_ob_level + 1)
{
ob_end_flush();
}
else
{
$this->add_output(ob_get_contents());
@ob_end_clean();
}
}
/**
* Display Output
*
* All "view" data is automatically put into this variable by the controller class:
*
* $this->final_output
*
* This function sends the finalized output data to the browser along
* with any server headers and profile data. It also stops the
* benchmark timer so the page rendering speed and memory usage can be shown.
*
* @access public
* @return mixed
*/
function _display($output = '')
{
// Note: We use globals because we can't use $CI =& get_instance()
// since this function is sometimes called by the caching mechanism,
// which happens before the CI super object is available.
global $BM, $CFG;
// Grab the super object if we can.
if (class_exists('CI_Controller'))
{
$CI =& get_instance();
}
// --------------------------------------------------------------------
// Set the output data
if ($output == '')
{
$output =& $this->final_output;
}
// --------------------------------------------------------------------
// Do we need to write a cache file? Only if the controller does not have its
// own _output() method and we are not dealing with a cache file, which we
// can determine by the existence of the $CI object above
if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
{
$this->_write_cache($output);
}
// --------------------------------------------------------------------
// Parse out the elapsed time and memory usage,
// then swap the pseudo-variables with the data
$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
if ($this->parse_exec_vars === TRUE)
{
$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
$output = str_replace('{elapsed_time}', $elapsed, $output);
$output = str_replace('{memory_usage}', $memory, $output);
}
// --------------------------------------------------------------------
// Is compression requested?
if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE)
{
if (extension_loaded('zlib'))
{
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
{
ob_start('ob_gzhandler');
}
}
}
// --------------------------------------------------------------------
// Are there any server headers to send?
if (count($this->headers) > 0)
{
foreach ($this->headers as $header)
{
@header($header[0], $header[1]);
log_message('debug', "header '$header[0], $header[1]' set.");
}
}
// --------------------------------------------------------------------
// Are there any cookies to set?
if (count($this->cookies) > 0)
{
foreach ($this->cookies as $cookie)
{
call_user_func_array ( 'setcookie' , $cookie );
log_message('debug', "cookie '".join(', ', $cookie)."' set.");
}
}
// --------------------------------------------------------------------
// If not we know we are dealing with a cache file so we'll
// simply echo out the data and exit.
if ( ! isset($CI))
{
echo $output;
log_message('debug', "Final output sent to browser");
log_message('debug', "Total execution time: ".$elapsed);
return TRUE;
}
// --------------------------------------------------------------------
// Do we need to generate profile data?
// If so, load the Profile class and run it.
if ($this->enable_profiler == TRUE)
{
$CI->load->library('profiler');
if ( ! empty($this->_profiler_sections))
{
$CI->profiler->set_sections($this->_profiler_sections);
}
// If the output data contains closing </body> and </html> tags
// we will remove them and add them back after we insert the profile data
if (preg_match("|</body>.*?</html>|is", $output))
{
$output = preg_replace("|</body>.*?</html>|is", '', $output);
$output .= $CI->profiler->run();
$output .= '</body></html>';
}
else
{
$output .= $CI->profiler->run();
}
}
// --------------------------------------------------------------------
// Does the controller contain a function named _output()?
// If so send the output there. Otherwise, echo it.
if (method_exists($CI, '_output'))
{
$CI->_output($output);
}
else
{
echo $output; // Send it to the browser!
}
log_message('debug', "Final output sent to browser");
log_message('debug', "Total execution time: ".$elapsed);
}
// --------------------------------------------------------------------
}
/* End of file CIU_Output.php */
/* Location: ./application/third_party/CIUnit/core/CIU_Output.php */

View File

@ -0,0 +1,419 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* System Initialization File
*
* Loads the base classes and executes the request.
*
* @package CodeIgniter
* @subpackage codeigniter
* @category Front-controller
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/
*/
/**
* CodeIgniter Version
*
* @var string
*
*/
define('CI_VERSION', '2.1.0');
/**
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
*
* @var boolean
*
*/
define('CI_CORE', FALSE);
/*
* ------------------------------------------------------
* Load the global functions
* ------------------------------------------------------
*/
require(CIUPATH.'core/Common.php');
require(BASEPATH.'core/Common.php');
/*
* ------------------------------------------------------
* Load the framework constants
* ------------------------------------------------------
*/
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
{
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
}
else
{
require(APPPATH.'config/constants.php');
}
/*
* ------------------------------------------------------
* Define a custom error handler so we can log PHP errors
* ------------------------------------------------------
*/
set_error_handler('_exception_handler');
if ( ! is_php('5.3'))
{
@set_magic_quotes_runtime(0); // Kill magic quotes
}
/*
* ------------------------------------------------------
* Set the subclass_prefix
* ------------------------------------------------------
*
* Normally the "subclass_prefix" is set in the config file.
* The subclass prefix allows CI to know if a core class is
* being extended via a library in the local application
* "libraries" folder. Since CI allows config items to be
* overriden via data set in the main index. php file,
* before proceeding we need to know if a subclass_prefix
* override exists. If so, we will set this value now,
* before any classes are loaded
* Note: Since the config file data is cached it doesn't
* hurt to load it here.
*/
if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}
/*
* ------------------------------------------------------
* Set a liberal script execution time limit
* ------------------------------------------------------
*/
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
@set_time_limit(300);
}
/*
* ------------------------------------------------------
* Start the timer... tick tock tick tock...
* ------------------------------------------------------
*/
$BM =& load_class('Benchmark', 'core');
$GLOBALS['BM'] =& $BM;
$BM->mark('total_execution_time_start');
$BM->mark('loading_time:_base_classes_start');
/*
* ------------------------------------------------------
* Instantiate the hooks class
* ------------------------------------------------------
*/
$EXT =& load_class('Hooks', 'core');
$GLOBALS['EXT'] =& $EXT;
/*
* ------------------------------------------------------
* Is there a "pre_system" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_system');
/*
* ------------------------------------------------------
* Instantiate the config class
* ------------------------------------------------------
*/
$CFG =& load_class('Config', 'core');
$GLOBALS['CFG'] =& $CFG;
// Do we have any manually set config items in the index.php file?
if (isset($assign_to_config))
{
$CFG->_assign_to_config($assign_to_config);
}
/*
* ------------------------------------------------------
* Instantiate the UTF-8 class
* ------------------------------------------------------
*
* Note: Order here is rather important as the UTF-8
* class needs to be used very early on, but it cannot
* properly determine if UTf-8 can be supported until
* after the Config class is instantiated.
*
*/
$UNI =& load_class('Utf8', 'core');
$GLOBALS['UNI'] =& $UNI;
/*
* ------------------------------------------------------
* Instantiate the URI class
* ------------------------------------------------------
*/
$URI =& load_class('URI', 'core');
$GLOBALS['URI'] =& $URI;
/*
* ------------------------------------------------------
* Instantiate the routing class and set the routing
* ------------------------------------------------------
*/
$RTR =& load_class('Router', 'core');
$GLOBALS['RTR'] =& $RTR;
//$RTR->_set_routing();
// Set any routing overrides that may exist in the main index file
if (isset($routing))
{
$RTR->_set_overrides($routing);
}
/*
* ------------------------------------------------------
* Instantiate the output class
* ------------------------------------------------------
*/
$OUT =& load_class('Output', 'core');
$GLOBALS['OUT'] =& $OUT;
/*
* ------------------------------------------------------
* Is there a valid cache file? If so, we're done...
* ------------------------------------------------------
*/
// I am not going to worry about a cache, right?
/*
if ($EXT->_call_hook('cache_override') === FALSE)
{
if ($OUT->_display_cache($CFG, $URI) == TRUE)
{
exit;
}
}
*/
/*
* -----------------------------------------------------
* Load the security class for xss and csrf support
* -----------------------------------------------------
*/
$SEC =& load_class('Security', 'core');
$GLOBALS['SEC'] =& $SEC;
/*
* ------------------------------------------------------
* Load the Input class and sanitize globals
* ------------------------------------------------------
*/
$IN =& load_class('Input', 'core');
$GLOBALS['IN'] =& $IN;
/*
* ------------------------------------------------------
* Load the Language class
* ------------------------------------------------------
*/
$LANG =& load_class('Lang', 'core');
/*
* ------------------------------------------------------
* Load the app controller and local controller
* ------------------------------------------------------
*
*/
// Load the base controller class
require BASEPATH.'core/Controller.php';
function &get_instance()
{
return CI_Controller::get_instance();
}
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
{
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
}
if (defined('CIUnit_Version') === FALSE)
{
// Load the local application controller
// Note: The Router class automatically validates the controller path using the router->_validate_request().
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
{
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
// Set a mark point for benchmarking
$BM->mark('loading_time:_base_classes_end');
/*
* ------------------------------------------------------
* Security check
* ------------------------------------------------------
*
* None of the functions in the app controller or the
* loader class can be called via the URI, nor can
* controller functions that begin with an underscore
*/
$class = $RTR->fetch_class();
$method = $RTR->fetch_method();
if ( ! class_exists($class)
OR strncmp($method, '_', 1) == 0
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
)
{
if ( ! empty($RTR->routes['404_override']))
{
$x = explode('/', $RTR->routes['404_override']);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
{
show_404("{$class}/{$method}");
}
include_once(APPPATH.'controllers/'.$class.'.php');
}
}
else
{
show_404("{$class}/{$method}");
}
}
/*
* ------------------------------------------------------
* Is there a "pre_controller" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('pre_controller');
/*
* ------------------------------------------------------
* Instantiate the requested controller
* ------------------------------------------------------
*/
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
$CI = new $class();
/*
* ------------------------------------------------------
* Is there a "post_controller_constructor" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('post_controller_constructor');
/*
* ------------------------------------------------------
* Call the requested method
* ------------------------------------------------------
*/
// Is there a "remap" function? If so, we call it instead
if (method_exists($CI, '_remap'))
{
$CI->_remap($method, array_slice($URI->rsegments, 2));
}
else
{
// is_callable() returns TRUE on some versions of PHP 5 for private and protected
// methods, so we'll use this workaround for consistent behavior
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
{
// Check and see if we are using a 404 override and use it.
if ( ! empty($RTR->routes['404_override']))
{
$x = explode('/', $RTR->routes['404_override']);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
{
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
{
show_404("{$class}/{$method}");
}
include_once(APPPATH.'controllers/'.$class.'.php');
unset($CI);
$CI = new $class();
}
}
else
{
show_404("{$class}/{$method}");
}
}
// Call the requested method.
// Any URI segments present (besides the class/function) will be passed to the method for convenience
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
}
// Mark a benchmark end point
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
/*
* ------------------------------------------------------
* Is there a "post_controller" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('post_controller');
/*
* ------------------------------------------------------
* Send the final rendered output to the browser
* ------------------------------------------------------
*/
if ($EXT->_call_hook('display_override') === FALSE)
{
$OUT->_display();
}
/*
* ------------------------------------------------------
* Is there a "post_system" hook?
* ------------------------------------------------------
*/
$EXT->_call_hook('post_system');
/*
* ------------------------------------------------------
* Close the DB connection if one exists
* ------------------------------------------------------
*/
if (class_exists('CI_DB') AND isset($CI->db))
{
$CI->db->close();
}
}
/* End of file CodeIgniter.php */
/* Location: ./application/third_party/CIUnit/core/CodeIgniter.php */

188
application/third_party/CIUnit/core/Common.php vendored Executable file
View File

@ -0,0 +1,188 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Changed some things in here for CIUnit
*/
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Common Functions
*
* Loads the base classes and executes the request.
*
* @package CodeIgniter
* @subpackage codeigniter
* @category Common Functions
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/
*/
// ------------------------------------------------------------------------
/**
* Class registry
*
* This function acts as a singleton. If the requested class does not
* exist it is instantiated and set to a static variable. If it has
* previously been instantiated the variable is returned.
*
* @access public
* @param string the class name being requested
* @param string the directory where the class should be found
* @param string the class name prefix
* @return object
*/
if ( ! function_exists('load_class'))
{
function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
{
static $_classes = array();
// Does the class exist? If so, we're done...
if (isset($_classes[$class]))
{
return $_classes[$class];
}
$name = FALSE;
// Look for the class first in the native system/libraries folder
// thenin the local application/libraries folder
// then in the ciunit/core folder
foreach (array(BASEPATH, APPPATH, CIUPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name = $prefix.$class;
if (class_exists($name) === FALSE)
{
require($path.$directory.'/'.$class.'.php');
}
break;
}
}
// Is the request a class extension? If so we load it too
if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
{
$name = config_item('subclass_prefix').$class;
if (class_exists($name) === FALSE)
{
require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
}
}
// Does the class have a CIU class extension?
if (file_exists(CIUPATH.'/core/'.config_item('ciu_subclass_prefix').$class.'.php'))
{
$name = config_item('ciu_subclass_prefix').$class;
if (class_exists($name) === FALSE)
{
require(CIUPATH.'/core/'.config_item('ciu_subclass_prefix').$class.'.php');
}
}
// Did we find the class?
if ($name === FALSE)
{
// Note: We use exit() rather then show_error() in order to avoid a
// self-referencing loop with the Excptions class
exit('Unable to locate the specified class: '.$class.'.php');
}
// Keep track of what we just loaded
is_loaded($class);
$_classes[$class] = new $name();
return $_classes[$class];
}
}
// --------------------------------------------------------------------
/**
* Loads the main config.php file
*
* This function lets us grab the config file even if the Config class
* hasn't been instantiated yet
*
* @access private
* @return array
*/
if ( ! function_exists('get_config'))
{
function get_config($replace = array())
{
static $_config;
if (isset($_config))
{
return $_config[0];
}
// Is the config file in the environment folder?
if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
{
$file_path = APPPATH.'config/config.php';
}
// Fetch the config file
if ( ! file_exists($file_path))
{
exit('The configuration file does not exist.');
}
require($file_path);
// Fetch the CIU config file
if ( ! file_exists(CIUPATH .'config/config.php'))
{
exit('The configuration file does not exist.');
}
require(CIUPATH.'config/config.php');
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
{
exit('Your config file does not appear to be formatted correctly.');
}
// Are any values being dynamically replaced?
if (count($replace) > 0)
{
foreach ($replace as $key => $val)
{
if (isset($config[$key]))
{
$config[$key] = $val;
}
}
}
return $_config[0] =& $config;
}
}
/* End of file Common.php */
/* Location: ./application/third_party/CIUnit/core/Common.php */

View File

@ -0,0 +1,3 @@
Overwriting some of the CodeIgniter base functionality.
CLI is just different.

View File

@ -0,0 +1,62 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter URL Helpers
*
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/url_helper.html
*/
// ------------------------------------------------------------------------
/**
* 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)
{
if ( ! preg_match('#^https?://#i', $uri))
{
$uri = site_url($uri);
}
switch($method)
{
case 'refresh' : $GLOBALS['OUT']->set_header("Refresh:0;url=".$uri);
break;
default : $GLOBALS['OUT']->set_header("Location: ".$uri, TRUE, $http_response_code);
break;
}
}
}
/* End of file CIU_url_helper.php */
/* Location: ./application/third_party/CIUnit/helpers/CIU_url_helper.php */

15
application/third_party/CIUnit/index.html vendored Executable file
View File

@ -0,0 +1,15 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body bgcolor='#ffffff'>
<p>Directory access is forbidden.<p>
</body>
</html>

View File

@ -0,0 +1,82 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* CodeIgniter source modified for CIUnit
*
* If you use MY_Session, change the paraent class.
*/
class CIU_Session extends MY_Session {
/**
* Destroy the current session
*
* @access public
* @return void
*/
function sess_destroy()
{
// Kill the session DB row
if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
{
$this->CI->db->where('session_id', $this->userdata['session_id']);
$this->CI->db->delete($this->sess_table_name);
}
// Kill the cookie: modified for CIUnit
$array = array(
$this->sess_cookie_name,
addslashes(serialize(array())),
($this->now - 31500000),
$this->cookie_path,
$this->cookie_domain,
0
);
$this->CI->output->set_cookie($array);
}
// --------------------------------------------------------------------
/**
* Write the session cookie
*
* @access public
* @return void
*/
function _set_cookie($cookie_data = NULL)
{
if (is_null($cookie_data))
{
$cookie_data = $this->userdata;
}
// Serialize the userdata for the cookie
$cookie_data = $this->_serialize($cookie_data);
if ($this->sess_encrypt_cookie == TRUE)
{
$cookie_data = $this->CI->encrypt->encode($cookie_data);
}
else
{
// if encryption is not used, we provide an md5 hash to prevent userside tampering
$cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key);
}
$expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time();
// Set the cookie: modified for CIUnit
$array = array(
$this->sess_cookie_name,
$cookie_data,
$expire,
$this->cookie_path,
$this->cookie_domain,
$this->cookie_secure
);
$this->CI->output->set_cookie($array);
}
}
/* End of file CIU_Session.php */
/* Location: ./application/third_party/CIUnit/libraries/CIU_Session.php */

View File

@ -0,0 +1,256 @@
<?php
/*
* fooStack, CIUnit for CodeIgniter
* Copyright (c) 2008-2009 Clemens Gruenberger
* Released under the MIT license, see:
* http://www.opensource.org/licenses/mit-license.php
*/
//load Testing
require_once CIUPATH . 'libraries/CIUnitTestCase.php';
/**
* CIUnit Class
* guides CI to behave nicely during tests..
*
* during the tests you can use:
*
* in setUp function:
* $this->CI = set_controller('controller_to_test');
* to set a different CI controller active
*
* use your controller functions simply like:
* $this->CI->function();
*
* created browser output is accessible like so
* $output = output();
* this function yields only once and is then reset to an empty string
*
* template vars like so:
* $vars = viewvars();
* they are also reset after this call
*/
class CIUnit {
private static $instance;
public static $controller;
public static $current;
public static $controllers = array();
public static $spyc;
public static $fixture;
/**
* If this class is suppose to be a Singleton shouldn't the constructor be private?
* Correct me if I am wrong but this doesn't prevent multiple instances of this class.
*/
public function __construct()
{
self::$instance =& $this;
}
public function &get_CIU()
{
return self::$instance;
}
public static function &set_controller($controller = 'CI_Controller', $path = FALSE)
{
$controller_name = array_pop(explode('/', $controller));
//echo "\nc name ".$controller_name;
//is it the current controller?
if ($controller_name == self::$current)
{
//we have nothing to do, return current controller
//echo "current found!"; die();
output();
viewvars();
return self::$controller;
}
// the current controller must be archieved before littered
$loader =& load_class('Loader', 'core');
// reset all loaded data
$loader->reset();
//echo 'Var Dump of self::$controllers -- ';
//var_dump(self::$controllers);
/*
=========================================================
I don't understand this section of code.
self::$controllers[self::$current] is never set when testing
models. Maybe it will be set when testing controllers?
=========================================================
if (isset(self::$controllers[self::$current]))
{
self::$controllers[self::$current]['models'] = $loader->_ci_models;
//this might be an update if it was there before
// FIXME, all additional properties of the loader / controllers
// that have to be reset must go in some test config file..
//'components' => $loader->_ci_components,
//'classes' => $loader->_ci_classes
}
===================================================
I don't understand why this code is clearing out
all the loaded components such as autoloaded models
-- this is very frustrating
==================================================
//clean up the current controllers mess
//reset models
$loader->_ci_models = array();
//reset components
//$loader->_ci_components = array();
//reset saved queries
self::$controller->db->queries = array();
*/
//clean output / viewvars as well;
if (isset(self::$controller->output))
{
output();
viewvars();
}
//the requested controller was loaded before?
if (isset(self::$controllers[$controller_name]))
{
//echo "saved found! $controller_name";
//load it
$old =& self::$controllers[$controller_name];
self::$controller =& $old['address'];
self::$current = $controller_name;
//$loader->_ci_models = $old['models'];
//$loader->_ci_components = $old['components'];
//$loader->_ci_classes = &$old['classes'];
}
else
{
//echo "load new $controller_name";
//it was not loaded before
if ( ! class_exists($controller_name))
{
if ($path && file_exists($path . $controller . EXT))
{
include_once($path . $controller . EXT);
}
else
{
include_once(APPPATH . 'controllers/' . $controller . EXT);
}
}
self::$current = $controller_name;
self::$controllers[$controller_name] = array(
'address' => new $controller_name(),
'models' => array()
);
self::$controller =& self::$controllers[$controller_name]['address'];
}
// var_dump(self::$controllers); die();
// var_dump(self::$controller); die();
//CI_Base::$instance = &self::$controller; //so get_instance() provides the correct controller
return self::$controller;
}
public static function &get_controller()
{
return self::$controller;
}
/**
* get filenames eg for running test suites
* $path is relative
*/
public static function files($pattern, $path = ".", $addpath = FALSE)
{
// Swap directory separators to Unix style for consistency
$path = str_replace("\\", "/", $path);
if (substr($path, -1) !== "/")
{
$path .= "/";
}
$dir_handle = @opendir($path) or die("Unable to open $path");
$outarr = array();
while ( false != ($file = readdir($dir_handle)) )
{
if (preg_match($pattern, $file))
{
if ($addpath)
{
$file = $path . $file;
}
$outarr[] = $file;
}
}
//could also use preg_grep!
closedir($dir_handle);
return $outarr;
}
}
//=== convenience functions ===
// instead of referring to CIUnit directly
/**
* retrieves current CIUnit Class Singleton
*/
function &get_CIU()
{
return CIUnit::get_CIU();
}
/**
* sets CI controller
*/
function &set_controller($controller = 'CI_Controller', $path = FALSE)
{
return CIUnit::set_controller($controller, $path);
}
/**
* retrieves current CI controller from CIUnit
*/
function &get_controller()
{
return CIUnit::get_controller();
}
/**
* retrieves the cached output from the output class
* and resets it
*/
function output()
{
return CIUnit::$controller->output->pop_output();
}
/**
* retrieves the cached template vars from the loader class (stored here for assignment to views)
* and resets them
*/
function viewvars()
{
if( isset(CIUnit::$controller->load->_ci_cached_vars) )
{
$out = CIUnit::$controller->load->_ci_cached_vars;
CIUnit::$controller->load->_ci_cached_vars = array();
return $out;
}
return array();
}
/* End of file CIUnit.php */
/* Location: ./application/third_party/CIUnit/libraries/CIUnit.php */

View File

@ -0,0 +1,222 @@
<?php
/*
* fooStack, CIUnit for CodeIgniter
* Copyright (c) 2008-2009 Clemens Gruenberger
* Released under the MIT license, see:
* http://www.opensource.org/licenses/mit-license.php
*/
/**
* Extending the default phpUnit Framework_TestCase Class
* providing eg. fixtures, custom assertions, utilities etc.
*/
class CIUnit_TestCase extends PHPUnit_Framework_TestCase
{
// ------------------------------------------------------------------------
/**
* An associative array of table names. The order of the fixtures
* determines the loading and unloading sequence of the fixtures. This is
* to help account for foreign key restraints in databases.
*
* For example:
* $tables = array(
* 'group' => 'group',
* 'user' => 'user',
* 'user_group' => 'user_group'
* 'table_a' => 'table_a_01'
* );
*
* Note: To test different data scenarios for a single database, create
* different fixtures.
*
* For example:
* $tables = array(
* 'table_a' => 'table_a_02'
* );
*
* @var array
*/
protected $tables = array();
// ------------------------------------------------------------------------
/**
* The CodeIgniter Framework Instance
*
* @var object
*/
public $CI;
// ------------------------------------------------------------------------
/**
* Constructor
*
* @param string $name
* @param array $data
* @param string $dataName
*/
public function __construct($name = NULL, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->CI =& get_instance();
log_message('debug', get_class($this).' CIUnit_TestCase initialized');
}
/**
* Set Up
*
* This method will run before every test.
*
* @return void
*
* @author Eric Jones
*/
protected function setUp()
{
// Only run if the $tables attribute is set.
if ( ! empty($this->tables))
{
$this->dbfixt($this->tables);
}
}
/**
* Tear Down
*
* This method will run after every test.
*
* @return void
*
* @author Eric Jones
*/
protected function tearDown()
{
// Only run if the $tables attribute is set.
if ( ! empty($this->tables))
{
$this->dbfixt_unload($this->tables);
}
}
/**
* loads a database fixture
* for each given fixture, we look up the yaml file and insert that into the corresponding table
* names are by convention
* 'users' -> look for 'users_fixt.yml' fixture: 'fixtures/users_fixt.yml'
* table is assumed to be named 'users'
* dbfixt can have multiple strings as arguments, like so:
* $this->dbfixt('users', 'items', 'prices');
*/
protected function dbfixt($table_fixtures)
{
if (is_array($table_fixtures))
{
$this->load_fixt($table_fixtures);
}
else
{
$table_fixtures = func_get_args();
$this->load_fixt($table_fixtures);
}
/**
* This is to allow the Unit Tester to specifiy different fixutre files for
* a given table. An example would be the testing of two different senarios
* of data in the database.
*
* @see CIUnitTestCase::tables
*/
foreach($table_fixtures as $table => $fixt )
{
$fixt_name = $fixt . '_fixt';
$table = is_int($table) ? $fixt : $table;
if (!empty($this->$fixt_name))
{
CIUnit::$fixture->load($table, $this->$fixt_name);
}
else
{
die("The fixture {$fixt_name} failed to load properly\n");
}
}
log_message('debug', 'Table fixtures "' . join('", "', $table_fixtures) . '" loaded');
}
/**
* DBFixt Unload
*
* Since there may be foreign key dependencies in the database, we can't just
* truncate tables in random order. This method attempts to truncate the
* tables by reversing the order of the $table attribute.
*
* @param array $table_fixtures Typically this will be the class attribute $table.
* @param boolean $reverse Should the method reverse the $table_fixtures array
* before the truncating the tables?
*
* @return void
*
* @see CIUnitTestCase::table
*
* @uses CIUnit::fixture
* @uses Fixture::unload()
*
* @author Eric Jones <eric.web.email@gmail.com>
*/
protected function dbfixt_unload(array $table_fixtures, $reverse = true)
{
// Should we reverse the order of loading?
// Helps with truncating tables with foreign key dependencies.
if ($reverse)
{
// Since the loading of tables took into account foreign key
// dependencies we should be able to just reverse the order
// of the database load. Right??
$table_fixtures = array_reverse($table_fixtures, true);
}
// Iterate over the array unloading the tables
foreach ($table_fixtures as $table => $fixture)
{
CIUnit::$fixture->unload($table);
log_message('debug', 'Table fixture "' . $fixture . '" unloaded');
}
}
/**
* fixture wrapper, for arbitrary number of arguments
*/
function fixt()
{
$fixts = func_get_args();
$this->load_fixt($fixts);
}
/**
* loads a fixture from a yaml file
*/
protected function load_fixt($fixts)
{
foreach ( $fixts as $fixt )
{
$fixt_name = $fixt . '_fixt';
if (file_exists(TESTSPATH . 'fixtures/' . $fixt . '_fixt.yml')) {
$this->$fixt_name = CIUnit::$spyc->loadFile(TESTSPATH . 'fixtures/' . $fixt . '_fixt.yml');
}
else
{
die('The file '. TESTSPATH . 'fixtures/' . $fixt . '_fixt.yml doesn\'t exist.');
}
}
}
}
/* End of file CIUnitTestCase.php */
/* Location: ./application/third_party/CIUnit/libraries/CIUnitTestCase.php */

View File

@ -0,0 +1,84 @@
<?php
/*
* fooStack, CIUnit for CodeIgniter
* Copyright (c) 2008-2009 Clemens Gruenberger
* Released under the MIT license, see:
* http://www.opensource.org/licenses/mit-license.php
*/
/**
* Fixture Class
* loads fixtures
* can be used with CIUnit
*/
class Fixture {
function __construct()
{
//security measure 1: only load if CIUnit is loaded
if ( ! defined('CIUnit_Version') )
{
exit('can\'t load fixture library class when not in test mode!');
}
}
/**
* loads fixture data $fixt into corresponding table
*/
function load($table, $fixt)
{
$this->_assign_db();
// $fixt is supposed to be an associative array
// E.g. outputted by spyc from reading a YAML file
$this->CI->db->simple_query('truncate table ' . $table . ';');
if ( ! empty($fixt))
{
$this->CI->db->insert_batch($table, $fixt);
}
$nbr_of_rows = sizeof($fixt);
log_message('debug',
"Data fixture for db table '$table' loaded - $nbr_of_rows rows");
}
public function unload($table)
{
$this->_assign_db();
$Q = TRUE;
//$Q = $this->CI->db->simple_query('truncate table ' . $table . ';');
if (!$Q) {
echo $this->CI->db->call_function('error', $this->CI->db->conn_id);
echo "\n";
echo "Failed to truncate the table ".$table."\n\n";
}
}
private function _assign_db()
{
if ( ! isset($this->CI->db) OR
! isset($this->CI->db->database) )
{
$this->CI =& get_instance();
$this->CI->load->database();
}
//security measure 2: only load if used database ends on '_test'
$len = strlen($this->CI->db->database);
if ( substr($this->CI->db->database, $len-5, $len) != '_test' )
{
die("\nSorry, the name of your test database must end on '_test'.\n".
"This prevents deleting important data by accident.\n");
}
}
}
/* End of file Fixture.php */
/* Location: ./application/third_party/CIUnit/libraries/Fixture.php */

View File

@ -0,0 +1,434 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.3.1
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Unit Testing Class
*
* Simple testing class
*
* @package CodeIgniter
* @subpackage Libraries
* @category UnitTesting
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/uri.html
*/
class CI_Unit_test {
var $active = TRUE;
var $results = array();
var $strict = FALSE;
var $_template = NULL;
var $_template_rows = NULL;
var $_test_items_visible = array();
public function __construct()
{
// These are the default items visible when a test is run.
$this->_test_items_visible = array (
'test_name',
'test_datatype',
'res_datatype',
'result',
'file',
'line',
'notes'
);
log_message('debug', "Unit Testing Class Initialized");
}
// --------------------------------------------------------------------
/**
* Run the tests
*
* Runs the supplied tests
*
* @access public
* @param array
* @return void
*/
function set_test_items($items = array())
{
if ( ! empty($items) AND is_array($items))
{
$this->_test_items_visible = $items;
}
}
// --------------------------------------------------------------------
/**
* Run the tests
*
* Runs the supplied tests
*
* @access public
* @param mixed
* @param mixed
* @param string
* @return string
*/
function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '')
{
if ($this->active == FALSE)
{
return FALSE;
}
if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
{
$expected = str_replace('is_float', 'is_double', $expected);
$result = ($expected($test)) ? TRUE : FALSE;
$extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
}
else
{
if ($this->strict == TRUE)
$result = ($test === $expected) ? TRUE : FALSE;
else
$result = ($test == $expected) ? TRUE : FALSE;
$extype = gettype($expected);
}
$back = $this->_backtrace();
$report[] = array (
'test_name' => $test_name,
'test_datatype' => gettype($test),
'res_datatype' => $extype,
'result' => ($result === TRUE) ? 'passed' : 'failed',
'file' => $back['file'],
'line' => $back['line'],
'notes' => $notes
);
$this->results[] = $report;
return($this->report($this->result($report)));
}
// --------------------------------------------------------------------
/**
* Generate a report
*
* Displays a table with the test data
*
* @access public
* @return string
*/
function report($result = array())
{
if (count($result) == 0)
{
$result = $this->result();
}
$CI =& get_instance();
$this->_parse_template();
$r = '';
if (php_sapi_name() !== 'cli')
{
$CI->load->language('unit_test');
foreach ($result as $res)
{
$table = '';
foreach ($res as $key => $val)
{
if ($key == $CI->lang->line('ut_result'))
{
if ($val == $CI->lang->line('ut_passed'))
{
$val = '<span style="color: #0C0;">'.$val.'</span>';
}
elseif ($val == $CI->lang->line('ut_failed'))
{
$val = '<span style="color: #C00;">'.$val.'</span>';
}
}
$temp = $this->_template_rows;
$temp = str_replace('{item}', $key, $temp);
$temp = str_replace('{result}', $val, $temp);
$table .= $temp;
}
$r .= str_replace('{rows}', $table, $this->_template);
}
return $r;
}
else
{
$CI->load->language('unit_test', 'english'); // force english
$passed = 0;
$failed = 0;
$failed_test = array();
$count = 0;
foreach ($result as $res)
{
if ($res['Result'] == 'Passed')
{
$passed += 1;
$count += 1;
}
elseif ($res['Result'] == 'Failed')
{
$failed += 1;
$failed_test[] = $res['Test Name'];
$count += 1;
}
}
$r1 = "Execute Unit Test!! \n\n";
$r2 = sprintf("All:%s Passed:%s Failed:%s\n", $count, $passed, $failed);
if (count($failed_test) > 0)
{
$r = $r1 . "\x1b[31m" . $r2 . "\x1b[0m" . sprintf("Failed Test: \n %s \n", implode("\n ", $failed_test));
}
else
{
$r = $r1 . "\x1b[32m" . $r2 . "\x1b[0m";
}
return $r;
}
}
// --------------------------------------------------------------------
/**
* Use strict comparison
*
* Causes the evaluation to use === rather than ==
*
* @access public
* @param bool
* @return null
*/
function use_strict($state = TRUE)
{
$this->strict = ($state == FALSE) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
/**
* Make Unit testing active
*
* Enables/disables unit testing
*
* @access public
* @param bool
* @return null
*/
function active($state = TRUE)
{
$this->active = ($state == FALSE) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
/**
* Result Array
*
* Returns the raw result data
*
* @access public
* @return array
*/
function result($results = array())
{
$CI =& get_instance();
if (php_sapi_name() === 'cli')
{
$CI->load->language('unit_test', 'english'); // force english
}
else
{
$CI->load->language('unit_test');
}
if (count($results) == 0)
{
$results = $this->results;
}
$retval = array();
foreach ($results as $result)
{
$temp = array();
foreach ($result as $key => $val)
{
if ( ! in_array($key, $this->_test_items_visible))
{
continue;
}
if (is_array($val))
{
foreach ($val as $k => $v)
{
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
{
$v = $line;
}
$temp[$CI->lang->line('ut_'.$k)] = $v;
}
}
else
{
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
{
$val = $line;
}
$temp[$CI->lang->line('ut_'.$key)] = $val;
}
}
$retval[] = $temp;
}
return $retval;
}
// --------------------------------------------------------------------
/**
* Set the template
*
* This lets us set the template to be used to display results
*
* @access public
* @param string
* @return void
*/
function set_template($template)
{
$this->_template = $template;
}
// --------------------------------------------------------------------
/**
* Generate a backtrace
*
* This lets us show file names and line numbers
*
* @access private
* @return array
*/
function _backtrace()
{
if (function_exists('debug_backtrace'))
{
$back = debug_backtrace();
$file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
$line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
return array('file' => $file, 'line' => $line);
}
return array('file' => 'Unknown', 'line' => 'Unknown');
}
// --------------------------------------------------------------------
/**
* Get Default Template
*
* @access private
* @return string
*/
function _default_template()
{
$this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">';
$this->_template .= '{rows}';
$this->_template .= "\n".'</table>';
$this->_template_rows = "\n\t".'<tr>';
$this->_template_rows .= "\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>';
$this->_template_rows .= "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>';
$this->_template_rows .= "\n\t".'</tr>';
}
// --------------------------------------------------------------------
/**
* Parse Template
*
* Harvests the data within the template {pseudo-variables}
*
* @access private
* @return void
*/
function _parse_template()
{
if ( ! is_null($this->_template_rows))
{
return;
}
if (is_null($this->_template))
{
$this->_default_template();
return;
}
if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
{
$this->_default_template();
return;
}
$this->_template_rows = $match['1'];
$this->_template = str_replace($match['0'], '{rows}', $this->_template);
}
}
// END Unit_test Class
/**
* Helper functions to test boolean true/false
*
*
* @access private
* @return bool
*/
function is_true($test)
{
return (is_bool($test) AND $test === TRUE) ? TRUE : FALSE;
}
function is_false($test)
{
return (is_bool($test) AND $test === FALSE) ? TRUE : FALSE;
}
/* End of file Unit_test.php */
/* Location: ./application/third_party/CIUnit/libraries/Unit_test.php */

View File

@ -0,0 +1,159 @@
#
# S P Y C
# a simple php yaml class
#
# Load this README!
# >> $readme = Spyc::YAMLLoad('README');
#
--- %YAML:1.1
title: Spyc -- a Simple PHP YAML Class
version: 0.4.5
authors: [chris wanstrath (chris@ozmm.org), vlad andersen (vlad.andersen@gmail.com)]
websites: [http://www.yaml.org, http://spyc.sourceforge.net]
license: [MIT License, http://www.opensource.org/licenses/mit-license.php]
copyright: "(c) 2005-2006 Chris Wanstrath, 2006-2009 Vlad Andersen"
tested on: [php 5.2.x]
installation: >
Copy spyc.php to a directory you can
access with your YAML-ready PHP script.
That's it!
about: >
From www.yaml.org:
"YAML(tm) (rhymes with 'camel') is a human-friendly, cross language,
Unicode based data serialization language designed around the common
native data structures of agile programming languages. It is broadly
useful for programming needs ranging from configuration files to
Internet messaging to object persistence to data auditing. Together
with the Unicode standard for characters, the YAML specification provides
all the information necessary to understand YAML Version 1.1 and to
creating programs that process YAML information.
YAML(tm) is a balance of the following design goals:
- YAML documents are very readable by humans.
- YAML interacts well with scripting languages.
- YAML uses host languages' native data structures.
- YAML has a consistent information model.
- YAML enables stream-based processing.
- YAML is expressive and extensible.
- YAML is easy to implement."
YAML makes a lot of sense. It's easy to use, easy to learn, and cool.
As the lucky stiff named why once said, "YAML is a beacon of light."
If you're new to YAML, may we suggest YAML In Five Minutes:
- http://yaml.kwiki.org/?YamlInFiveMinutes
If you don't have five minutes, realize that this README is a completely
valid YAML document. Dig in, load this or any YAML file into an array
with Spyc and see how easy it is to translate friendly text into usable
data.
The purpose of Spyc is to provide a pure PHP alternative to Syck, a
simple API for loading and dumping YAML documents, a YAML loader which
understands a usable subset of the YAML spec, and to further spread
the glory of YAML to the PHP masses.
If you're at all hesitant ("usable subset of YAML?!"), navigate
http://yaml.org/start.html. Spyc completely understands the YAML
document shown there, a document which has features way beyond the
scope of what normal config files might require. Try it for yourself,
and then start enjoying the peace of mind YAML brings to your life.
meat and a few potatoes:
- concept: Loading a YAML document into PHP
brief: >
$yaml will become an array of all the data in wicked.yaml
code: |
include('spyc.php');
$yaml = Spyc::YAMLLoad('wicked.yaml');
- concept: Loading a YAML string into PHP
brief: >
$array will look like this:
array('A YAML','document in a','string')
code: |
include('spyc.php');
$yaml = '- A YAML\n- document in a\n- string.';
$array = Spyc::YAMLLoad($yaml);
- concept: Dumping a PHP array to YAML
brief: >
$yaml will become a string of a YAML document created from
$array.
code: |
include('spyc.php');
$array['name'] = 'chris';
$array['sport'] = 'curbing';
$yaml = Spyc::YAMLDump($array);
prior art:
- who: [Brian Ingerson, Clark Evans, Oren Ben-Kiki]
why?: >
The YAML spec is really a piece of work, and these guys
did a great job on it. A simple and elegant language like
YAML was a long time coming and it's refreshing to know
such able minded individuals took the task to heart and
executed it with cunning and strength. In addition to
their various noteworthy contributions to YAML parsers
and related projects, YAML.pm's README is a treasure trove
of information for knowledge seekers. Thanks, guys.
- who: why the lucky stiff
why?: >
As the author of Syck, the code used in Ruby for the language's
YAML class and methods, why is indirectly (directly?) responsible
for my first exposure to YAML (as a config file in a Ruby web-app)
and the countless hours I spent playing with this sheik new data
format afterwards. Syck's README is a YAML file and thus the
inspiration for this file and, even, this very piece of software.
- who: Steve Howell
why?: >
Python's YAML implementation. PyYAML's README file is also YAML,
so it too inspired the YAML format of this README file.
- who: [Rasmus Lerdorf, Zeev Suraski, Andi Gutmans, et al]
why?: >
PHP is great at what it does best. It's also paid a lot of my bills.
Thanks.
bugs:
report: >
Please see Spyc's Sourceforge project page for information on reporting bugs.
speed: >
This implementation was not designed for speed. Rather, it
was designed for those who need a pure PHP implementation of
a YAML parser and who are not overly concerned with performance.
If you want speed, check out Syck.
depth: >
This parser is by no means a comprehensive YAML parser. For supported
features and future plans, check the website.
unicode: >
YAML is supposed to be unicode, but for now we're just using ASCII.
PHP has crappy unicode support but who knows what the future holds.
resources:
- http://www.yaml.org
- http://www.yaml.org/spec/
- http://yaml.kwiki.org/?YamlInFiveMinutes
- http://www.whytheluckystiff.net/syck/
- http://yaml4r.sourceforge.net/cookbook/
thanks:
- Adam Wood
- Daniel Ferreira
- Aaron Jensen
- Mike Thornton
- Fabien Potencier
- Mustafa Kumas

View File

@ -0,0 +1,25 @@
<?php
#
# S P Y C
# a simple php yaml class
#
# Feel free to dump an array to YAML, and then to load that YAML back into an
# array. This is a good way to test the limitations of the parser and maybe
# learn some basic YAML.
#
include('../spyc.php');
$array[] = 'Sequence item';
$array['The Key'] = 'Mapped value';
$array[] = array('A sequence','of a sequence');
$array[] = array('first' => 'A sequence','second' => 'of mapped values');
$array['Mapped'] = array('A sequence','which is mapped');
$array['A Note'] = 'What if your text is too long?';
$array['Another Note'] = 'If that is the case, the dumper will probably fold your text by using a block. Kinda like this.';
$array['The trick?'] = 'The trick is that we overrode the default indent, 2, to 4 and the default wordwrap, 40, to 60.';
$array['Old Dog'] = "And if you want\n to preserve line breaks, \ngo ahead!";
$array['key:withcolon'] = "Should support this to";
$yaml = Spyc::YAMLDump($array,4,60);

View File

@ -0,0 +1,25 @@
<?php
#
# S P Y C
# a simple php yaml class
# v0.2(.5)
#
# author: [chris wanstrath, chris@ozmm.org]
# websites: [http://www.yaml.org, http://spyc.sourceforge.net/]
# license: [MIT License, http://www.opensource.org/licenses/mit-license.php]
# copyright: (c) 2005-2006 Chris Wanstrath
#
include('../spyc.php');
$array = Spyc::YAMLLoad('../spyc.yaml');
echo '<pre><a href="spyc.yaml">spyc.yaml</a> loaded into PHP:<br/>';
print_r($array);
echo '</pre>';
echo '<pre>YAML Data dumped back:<br/>';
echo Spyc::YAMLDump($array);
echo '</pre>';

View File

@ -0,0 +1,16 @@
<?php
php5to4 ("../spyc.php", 'spyc-latest.php4');
function php5to4 ($src, $dest) {
$code = file_get_contents ($src);
$code = preg_replace ('#(public|private|protected)\s+\$#i', 'var \$', $code);
$code = preg_replace ('#(public|private|protected)\s+static\s+\$#i', 'var \$', $code);
$code = preg_replace ('#(public|private|protected)\s+function#i', 'function', $code);
$code = preg_replace ('#(public|private|protected)\s+static\s+function#i', 'function', $code);
$code = str_replace ('self::', '$this->', $code);
$f = fopen ($dest, 'w');
fwrite($f, $code);
fclose ($f);
print "Written to $dest.\n";
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,162 @@
<?php
#
# S P Y C
# a simple php yaml class
# v0.3
#
# author: [chris wanstrath, chris@ozmm.org]
# websites: [http://www.yaml.org, http://spyc.sourceforge.net/]
# license: [MIT License, http://www.opensource.org/licenses/mit-license.php]
# copyright: (c) 2005-2006 Chris Wanstrath
#
# We're gonna load a file into memory and see if we get what we expect.
# If not, we're gonna complain.
#
# Pretty lo-fi. Let's see if we can't get some unit testing going in the next,
# I dunno, 20 months? Alright. Go team.
#
error_reporting(E_ALL);
include('spyc.php4');
$yaml = Spyc::YAMLLoad('../spyc.yaml');
// print_r ($yaml);
# Added in .2
if ($yaml[1040] != "Ooo, a numeric key!")
die('Key: 1040 failed');
# Test mappings / types
if ($yaml['String'] != "Anyone's name, really.")
die('Key: String failed');
if ($yaml['Int'] !== 13)
die('Key: Int failed');
if ($yaml['True'] !== true)
die('Key: True failed');
if ($yaml['False'] !== false)
die('Key: False failed');
if ($yaml['Zero'] !== 0)
die('Key: Zero failed');
if (isset($yaml['Null']))
die('Key: Null failed');
if ($yaml['Float'] !== 5.34)
die('Key: Float failed');
# Test sequences
if ($yaml[0] != "PHP Class")
die('Sequence 0 failed');
if ($yaml[1] != "Basic YAML Loader")
die('Sequence 1 failed');
if ($yaml[2] != "Very Basic YAML Dumper")
die('Sequence 2 failed');
# A sequence of a sequence
if ($yaml[3] != array("YAML is so easy to learn.",
"Your config files will never be the same."))
die('Sequence 3 failed');
# Sequence of mappings
if ($yaml[4] != array("cpu" => "1.5ghz", "ram" => "1 gig",
"os" => "os x 10.4.1"))
die('Sequence 4 failed');
# Mapped sequence
if ($yaml['domains'] != array("yaml.org", "php.net"))
die("Key: 'domains' failed");
# A sequence like this.
if ($yaml[5] != array("program" => "Adium", "platform" => "OS X",
"type" => "Chat Client"))
die('Sequence 5 failed');
# A folded block as a mapped value
if ($yaml['no time'] != "There isn't any time for your tricks!\nDo you understand?")
die("Key: 'no time' failed");
# A literal block as a mapped value
if ($yaml['some time'] != "There is nothing but time\nfor your tricks.")
die("Key: 'some time' failed");
# Crazy combinations
if ($yaml['databases'] != array( array("name" => "spartan", "notes" =>
array( "Needs to be backed up",
"Needs to be normalized" ),
"type" => "mysql" )))
die("Key: 'databases' failed");
# You can be a bit tricky
if ($yaml["if: you'd"] != "like")
die("Key: 'if: you\'d' failed");
# Inline sequences
if ($yaml[6] != array("One", "Two", "Three", "Four"))
die("Sequence 6 failed");
# Nested Inline Sequences
if ($yaml[7] != array("One", array("Two", "And", "Three"), "Four", "Five"))
die("Sequence 7 failed");
# Nested Nested Inline Sequences
if ($yaml[8] != array( "This", array("Is", "Getting", array("Ridiculous", "Guys")),
"Seriously", array("Show", "Mercy")))
die("Sequence 8 failed");
# Inline mappings
if ($yaml[9] != array("name" => "chris", "age" => "young", "brand" => "lucky strike"))
die("Sequence 9 failed");
# Nested inline mappings
if ($yaml[10] != array("name" => "mark", "age" => "older than chris",
"brand" => array("marlboro", "lucky strike")))
die("Sequence 10 failed");
# References -- they're shaky, but functional
if ($yaml['dynamic languages'] != array('Perl', 'Python', 'PHP', 'Ruby'))
die("Key: 'dynamic languages' failed");
if ($yaml['compiled languages'] != array('C/C++', 'Java'))
die("Key: 'compiled languages' failed");
if ($yaml['all languages'] != array(
array('Perl', 'Python', 'PHP', 'Ruby'),
array('C/C++', 'Java')
))
die("Key: 'all languages' failed");
# Added in .2.2: Escaped quotes
if ($yaml[11] != "you know, this shouldn't work. but it does.")
die("Sequence 11 failed.");
if ($yaml[12] != "that's my value.")
die("Sequence 12 failed.");
if ($yaml[13] != "again, that's my value.")
die("Sequence 13 failed.");
if ($yaml[14] != "here's to \"quotes\", boss.")
die("Sequence 14 failed.");
if ($yaml[15] != array( 'name' => "Foo, Bar's", 'age' => 20))
die("Sequence 15 failed.");
if ($yaml[16] != array( 0 => "a", 1 => array (0 => 1, 1 => 2), 2 => "b"))
die("Sequence 16 failed.");
if ($yaml['endloop'] != "Does this line in the end indeed make Spyc go to an infinite loop?")
die("[endloop] failed.");
print "spyc.yaml parsed correctly\n";
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,196 @@
#
# S P Y C
# a simple php yaml class
#
# authors: [vlad andersen (vlad.andersen@gmail.com), chris wanstrath (chris@ozmm.org)]
# websites: [http://www.yaml.org, http://spyc.sourceforge.net/]
# license: [MIT License, http://www.opensource.org/licenses/mit-license.php]
# copyright: (c) 2005-2006 Chris Wanstrath, 2006-2009 Vlad Andersen
#
# spyc.yml - A file containing the YAML that Spyc understands.
---
# Mappings - with proper types
String: Anyone's name, really.
Int: 13
True: true
False: false
Zero: 0
Null: NULL
Float: 5.34
# A sequence
- PHP Class
- Basic YAML Loader
- Very Basic YAML Dumper
# A sequence of a sequence
-
- YAML is so easy to learn.
- Your config files will never be the same.
# Sequence of mappings
-
cpu: 1.5ghz
ram: 1 gig
os : os x 10.4.1
# Mapped sequence
domains:
- yaml.org
- php.net
# A sequence like this.
- program: Adium
platform: OS X
type: Chat Client
# A folded block as a mapped value
no time: >
There isn't any time
for your tricks!
Do you understand?
# A literal block as a mapped value
some time: |
There is nothing but time
for your tricks.
# Crazy combinations
databases:
- name: spartan
notes:
- Needs to be backed up
- Needs to be normalized
type: mysql
# You can be a bit tricky
"if: you'd": like
# Inline sequences
- [One, Two, Three, Four]
# Nested Inline Sequences
- [One, [Two, And, Three], Four, Five]
# Nested Nested Inline Sequences
- [This, [Is, Getting, [Ridiculous, Guys]], Seriously, [Show, Mercy]]
# Inline mappings
- {name: chris, age: young, brand: lucky strike}
# Nested inline mappings
- {name: mark, age: older than chris, brand: [marlboro, lucky strike]}
# References -- they're shaky, but functional
dynamic languages: &DLANGS
- Perl
- Python
- PHP
- Ruby
compiled languages: &CLANGS
- C/C++
- Java
all languages:
- *DLANGS
- *CLANGS
# Added in .2.2: Escaped quotes
- you know, this shouldn't work. but it does.
- 'that''s my value.'
- 'again, that\'s my value.'
- "here's to \"quotes\", boss."
# added in .2.3
- {name: "Foo, Bar's", age: 20}
# Added in .2.4: bug [ 1418193 ] Quote Values in Nested Arrays
- [a, ['1', "2"], b]
# Added in .2.4: malformed YAML
all
javascripts: [dom1.js, dom.js]
# Added in .2
1040: Ooo, a numeric key! # And working comments? Wow! Colons in comments: a menace (0.3).
hash_1: Hash #and a comment
hash_2: "Hash #and a comment"
"hash#3": "Hash (#) can appear in key too"
float_test: 1.0
float_test_with_quotes: '1.0'
float_inverse_test: 001
a_really_large_number: 115792089237316195423570985008687907853269984665640564039457584007913129639936 # 2^256
int array: [ 1, 2, 3 ]
array on several lines:
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]
morelesskey: "<value>"
array_of_zero: [0]
sophisticated_array_of_zero: {rx: {tx: [0]} }
switches:
- { row: 0, col: 0, func: {tx: [0, 1]} }
empty_sequence: [ ]
empty_hash: { }
special_characters: "[{]]{{]]"
asterisks: "*"
empty_key:
:
key: value
trailing_colon: "foo:"
multiline_items:
- type: SomeItem
values: [blah, blah, blah,
blah]
ints: [2, 54, 12,
2143]
many_lines: |
A quick
fox
jumped
over
a lazy
dog
werte:
1: nummer 1
0: Stunde 0
noindent_records:
- record1: value1
- record2: value2
"a:1": [1000]
"a:2":
- 2000
# [Endloop]
endloop: |
Does this line in the end indeed make Spyc go to an infinite loop?

View File

@ -0,0 +1,58 @@
<?php
require_once ("../spyc.php");
class DumpTest extends PHPUnit_Framework_TestCase {
private $files_to_test = array();
public function setUp() {
$this->files_to_test = array ('../spyc.yaml', 'failing1.yaml', 'indent_1.yaml', 'quotes.yaml');
}
public function testDump() {
foreach ($this->files_to_test as $file) {
$yaml = spyc_load(file_get_contents($file));
$dump = Spyc::YAMLDump ($yaml);
$yaml_after_dump = Spyc::YAMLLoad ($dump);
$this->assertEquals ($yaml, $yaml_after_dump);
}
}
public function testDumpWithQuotes() {
$Spyc = new Spyc();
$Spyc->setting_dump_force_quotes = true;
foreach ($this->files_to_test as $file) {
$yaml = $Spyc->load(file_get_contents($file));
$dump = $Spyc->dump ($yaml);
$yaml_after_dump = Spyc::YAMLLoad ($dump);
$this->assertEquals ($yaml, $yaml_after_dump);
}
}
public function testDumpArrays() {
$dump = Spyc::YAMLDump(array ('item1', 'item2', 'item3'));
$awaiting = "---\n- item1\n- item2\n- item3\n";
$this->assertEquals ($awaiting, $dump);
}
public function testDumpNumerics() {
$dump = Spyc::YAMLDump(array ('404', '405', '500'));
$awaiting = "---\n- 404\n- 405\n- 500\n";
$this->assertEquals ($awaiting, $dump);
}
public function testDumpAsterisks() {
$dump = Spyc::YAMLDump(array ('*'));
$awaiting = "---\n- '*'\n";
$this->assertEquals ($awaiting, $dump);
}
public function testEmpty() {
$dump = Spyc::YAMLDump(array("foo" => array()));
$awaiting = "---\nfoo: [ ]\n";
$this->assertEquals ($awaiting, $dump);
}
}

View File

@ -0,0 +1,57 @@
<?php
require_once ("../spyc.php");
class IndentTest extends PHPUnit_Framework_TestCase {
protected $Y;
protected function setUp() {
$this->Y = Spyc::YAMLLoad("indent_1.yaml");
}
public function testIndent_1() {
$this->assertEquals (array ('child_1' => 2, 'child_2' => 0, 'child_3' => 1), $this->Y['root']);
}
public function testIndent_2() {
$this->assertEquals (array ('child_1' => 1, 'child_2' => 2), $this->Y['root2']);
}
public function testIndent_3() {
$this->assertEquals (array (array ('resolutions' => array (1024 => 768, 1920 => 1200), 'producer' => 'Nec')), $this->Y['display']);
}
public function testIndent_4() {
$this->assertEquals (array (
array ('resolutions' => array (1024 => 768)),
array ('resolutions' => array (1920 => 1200)),
), $this->Y['displays']);
}
public function testIndent_5() {
$this->assertEquals (array (array (
'row' => 0,
'col' => 0,
'headsets_affected' => array (
array (
'ports' => array (0),
'side' => 'left',
)
),
'switch_function' => array (
'ics_ptt' => true
)
)), $this->Y['nested_hashes_and_seqs']);
}
public function testIndent_6() {
$this->assertEquals (array (
'h' => array (
array ('a' => 'b', 'a1' => 'b1'),
array ('c' => 'd')
)
), $this->Y['easier_nest']);
}
}

View File

@ -0,0 +1,305 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once ("../spyc.php");
class ParseTest extends PHPUnit_Framework_TestCase {
protected $yaml;
protected function setUp() {
$this->yaml = spyc_load_file('../spyc.yaml');
}
public function testMergeHashKeys() {
$Expected = array (
array ('step' => array('instrument' => 'Lasik 2000', 'pulseEnergy' => 5.4, 'pulseDuration' => 12, 'repetition' => 1000, 'spotSize' => '1mm')),
array ('step' => array('instrument' => 'Lasik 2000', 'pulseEnergy' => 5.4, 'pulseDuration' => 12, 'repetition' => 1000, 'spotSize' => '2mm')),
);
$Actual = spyc_load_file ('indent_1.yaml');
$this->assertEquals ($Expected, $Actual['steps']);
}
public function testDeathMasks() {
$Expected = array ('sad' => 2, 'magnificent' => 4);
$Actual = spyc_load_file ('indent_1.yaml');
$this->assertEquals ($Expected, $Actual['death masks are']);
}
public function testDevDb() {
$Expected = array ('adapter' => 'mysql', 'host' => 'localhost', 'database' => 'rails_dev');
$Actual = spyc_load_file ('indent_1.yaml');
$this->assertEquals ($Expected, $Actual['development']);
}
public function testNumericKey() {
$this->assertEquals ("Ooo, a numeric key!", $this->yaml[1040]);
}
public function testMappingsString() {
$this->assertEquals ("Anyone's name, really.", $this->yaml['String']);
}
public function testMappingsInt() {
$this->assertSame (13, $this->yaml['Int']);
}
public function testMappingsBooleanTrue() {
$this->assertSame (true, $this->yaml['True']);
}
public function testMappingsBooleanFalse() {
$this->assertSame (false, $this->yaml['False']);
}
public function testMappingsZero() {
$this->assertSame (0, $this->yaml['Zero']);
}
public function testMappingsNull() {
$this->assertSame (null, $this->yaml['Null']);
}
public function testMappingsFloat() {
$this->assertSame (5.34, $this->yaml['Float']);
}
public function testSeq0() {
$this->assertEquals ("PHP Class", $this->yaml[0]);
}
public function testSeq1() {
$this->assertEquals ("Basic YAML Loader", $this->yaml[1]);
}
public function testSeq2() {
$this->assertEquals ("Very Basic YAML Dumper", $this->yaml[2]);
}
public function testSeq3() {
$this->assertEquals (array("YAML is so easy to learn.",
"Your config files will never be the same."), $this->yaml[3]);
}
public function testSeqMap() {
$this->assertEquals (array("cpu" => "1.5ghz", "ram" => "1 gig",
"os" => "os x 10.4.1"), $this->yaml[4]);
}
public function testMappedSequence() {
$this->assertEquals (array("yaml.org", "php.net"), $this->yaml['domains']);
}
public function testAnotherSequence() {
$this->assertEquals (array("program" => "Adium", "platform" => "OS X",
"type" => "Chat Client"), $this->yaml[5]);
}
public function testFoldedBlock() {
$this->assertEquals ("There isn't any time for your tricks!\nDo you understand?", $this->yaml['no time']);
}
public function testLiteralAsMapped() {
$this->assertEquals ("There is nothing but time\nfor your tricks.", $this->yaml['some time']);
}
public function testCrazy() {
$this->assertEquals (array( array("name" => "spartan", "notes" =>
array( "Needs to be backed up",
"Needs to be normalized" ),
"type" => "mysql" )), $this->yaml['databases']);
}
public function testColons() {
$this->assertEquals ("like", $this->yaml["if: you'd"]);
}
public function testInline() {
$this->assertEquals (array("One", "Two", "Three", "Four"), $this->yaml[6]);
}
public function testNestedInline() {
$this->assertEquals (array("One", array("Two", "And", "Three"), "Four", "Five"), $this->yaml[7]);
}
public function testNestedNestedInline() {
$this->assertEquals (array( "This", array("Is", "Getting", array("Ridiculous", "Guys")),
"Seriously", array("Show", "Mercy")), $this->yaml[8]);
}
public function testInlineMappings() {
$this->assertEquals (array("name" => "chris", "age" => "young", "brand" => "lucky strike"), $this->yaml[9]);
}
public function testNestedInlineMappings() {
$this->assertEquals (array("name" => "mark", "age" => "older than chris",
"brand" => array("marlboro", "lucky strike")), $this->yaml[10]);
}
public function testReferences() {
$this->assertEquals (array('Perl', 'Python', 'PHP', 'Ruby'), $this->yaml['dynamic languages']);
}
public function testReferences2() {
$this->assertEquals (array('C/C++', 'Java'), $this->yaml['compiled languages']);
}
public function testReferences3() {
$this->assertEquals (array(
array('Perl', 'Python', 'PHP', 'Ruby'),
array('C/C++', 'Java')
), $this->yaml['all languages']);
}
public function testEscapedQuotes() {
$this->assertEquals ("you know, this shouldn't work. but it does.", $this->yaml[11]);
}
public function testEscapedQuotes_2() {
$this->assertEquals ( "that's my value.", $this->yaml[12]);
}
public function testEscapedQuotes_3() {
$this->assertEquals ("again, that's my value.", $this->yaml[13]);
}
public function testQuotes() {
$this->assertEquals ("here's to \"quotes\", boss.", $this->yaml[14]);
}
public function testQuoteSequence() {
$this->assertEquals ( array( 'name' => "Foo, Bar's", 'age' => 20), $this->yaml[15]);
}
public function testShortSequence() {
$this->assertEquals (array( 0 => "a", 1 => array (0 => 1, 1 => 2), 2 => "b"), $this->yaml[16]);
}
public function testHash_1() {
$this->assertEquals ("Hash", $this->yaml['hash_1']);
}
public function testHash_2() {
$this->assertEquals ('Hash #and a comment', $this->yaml['hash_2']);
}
public function testHash_3() {
$this->assertEquals ('Hash (#) can appear in key too', $this->yaml['hash#3']);
}
public function testEndloop() {
$this->assertEquals ("Does this line in the end indeed make Spyc go to an infinite loop?", $this->yaml['endloop']);
}
public function testReallyLargeNumber() {
$this->assertEquals ('115792089237316195423570985008687907853269984665640564039457584007913129639936', $this->yaml['a_really_large_number']);
}
public function testFloatWithZeros() {
$this->assertSame ('1.0', $this->yaml['float_test']);
}
public function testFloatWithQuotes() {
$this->assertSame ('1.0', $this->yaml['float_test_with_quotes']);
}
public function testFloatInverse() {
$this->assertEquals ('001', $this->yaml['float_inverse_test']);
}
public function testIntArray() {
$this->assertEquals (array (1, 2, 3), $this->yaml['int array']);
}
public function testArrayOnSeveralLines() {
$this->assertEquals (array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), $this->yaml['array on several lines']);
}
public function testmoreLessKey() {
$this->assertEquals ('<value>', $this->yaml['morelesskey']);
}
public function testArrayOfZero() {
$this->assertSame (array(0), $this->yaml['array_of_zero']);
}
public function testSophisticatedArrayOfZero() {
$this->assertSame (array('rx' => array ('tx' => array (0))), $this->yaml['sophisticated_array_of_zero']);
}
public function testSwitches() {
$this->assertEquals (array (array ('row' => 0, 'col' => 0, 'func' => array ('tx' => array(0, 1)))), $this->yaml['switches']);
}
public function testEmptySequence() {
$this->assertSame (array(), $this->yaml['empty_sequence']);
}
public function testEmptyHash() {
$this->assertSame (array(), $this->yaml['empty_hash']);
}
public function testEmptykey() {
$this->assertSame (array('' => array ('key' => 'value')), $this->yaml['empty_key']);
}
public function testMultilines() {
$this->assertSame (array(array('type' => 'SomeItem', 'values' => array ('blah', 'blah', 'blah', 'blah'), 'ints' => array(2, 54, 12, 2143))), $this->yaml['multiline_items']);
}
public function testManyNewlines() {
$this->assertSame ('A quick
fox
jumped
over
a lazy
dog', $this->yaml['many_lines']);
}
public function testWerte() {
$this->assertSame (array ('1' => 'nummer 1', '0' => 'Stunde 0'), $this->yaml['werte']);
}
/* public function testNoIndent() {
$this->assertSame (array(
array ('record1'=>'value1'),
array ('record2'=>'value2')
)
, $this->yaml['noindent_records']);
} */
public function testColonsInKeys() {
$this->assertSame (array (1000), $this->yaml['a:1']);
}
public function testColonsInKeys2() {
$this->assertSame (array (2000), $this->yaml['a:2']);
}
public function testSpecialCharacters() {
$this->assertSame ('[{]]{{]]', $this->yaml['special_characters']);
}
public function testAngleQuotes() {
$Quotes = Spyc::YAMLLoad('quotes.yaml');
$this->assertEquals (array ('html_tags' => array ('<br>', '<p>'), 'html_content' => array ('<p>hello world</p>', 'hello<br>world'), 'text_content' => array ('hello world')),
$Quotes);
}
public function testFailingColons() {
$Failing = Spyc::YAMLLoad('failing1.yaml');
$this->assertSame (array ('MyObject' => array ('Prop1' => array ('key1:val1'))),
$Failing);
}
}

View File

@ -0,0 +1,2 @@
MyObject:
Prop1: {key1:val1}

View File

@ -0,0 +1,53 @@
root:
child_1: 2
child_2: 0
child_3: 1
root2:
child_1: 1
# A comment
child_2: 2
displays:
- resolutions:
1024: 768
- resolutions:
1920: 1200
display:
- resolutions:
1024: 768
1920: 1200
producer: "Nec"
nested_hashes_and_seqs:
- { row: 0, col: 0, headsets_affected: [{ports: [0], side: left}], switch_function: {ics_ptt: true} }
easier_nest: { h: [{a: b, a1: b1}, {c: d}] }
steps:
- step: &id001
instrument: Lasik 2000
pulseEnergy: 5.4
pulseDuration: 12
repetition: 1000
spotSize: 1mm
- step:
<<: *id001
spotSize: 2mm
death masks are:
sad: 2
<<: {magnificent: 4}
login: &login
adapter: mysql
host: localhost
development:
database: rails_dev
<<: *login
"key": "value:"
colon_only: ":"

View File

@ -0,0 +1,8 @@
html_tags:
- <br>
- <p>
html_content:
- <p>hello world</p>
- hello<br>world
text_content:
- hello world

View File

@ -0,0 +1,38 @@
<?php if (isset($err)) : ?>
<?php if(is_array($err)) : ?>
<div class="err_wrap">
Fix the following errors:
<?php foreach ($err as $e): ?>
<p class="error"><?= $e ?></p>
<?php endforeach;?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php $this->load->view('account/side_nav'); ?>
<section class="right">
<form action="<?= site_url('account/password'); ?>" method="post">
<fieldset>
<legend>Change Password</legend>
<dl>
<dt><label for="user">New Password:</label></dt>
<dd>
<input type="password" name="pass" id="pass"
required="required" value="" size="10" />
<input type="password" name="pass1" id="pass1"
required="required" value="" size="10" />
</dd>
<dt><label for="pass">Old Password:</label></dt>
<dd>
<input type="password" name="old_pass" id="old_pass"
required="required" value="" size="10" />
</dd>
<dt>&nbsp;</dt>
<dd>
<input type="submit" name="pass_sub" value="Change Password" />
</dd>
</dl>
</fieldset>
</form>
</section>

View File

@ -0,0 +1,15 @@
<?php $link = $this->uri->segment(2) ?>
<aside id="left_nav" class="left">
<nav>
<ul>
<li <?= ($link == FALSE) ? 'class="active"':"";?>>
<span class="icon information"></span>
<a href="<?= site_url('account')?>">Your Account</a>
</li>
<li <?= ($link == "password") ? 'class="active"' : "";?>>
<span class="icon lock_edit"></span>
<a href="<?= site_url('account/password')?>">Change Password</a>
</li>
</ul>
</nav>
</aside>

View File

@ -0,0 +1,48 @@
<?php if($this->session->userdata('username') != 'guest') $this->load->view('account/side_nav'); //Not the guest account ?>
<section id="task_view" class="right">
<h1>Your Account</h1>
<dl>
<dt>User Id</dt>
<dd><?= ($this->session->userdata('num_format') == 1) ? $this->todo->kanji_num($this->session->userdata('uid')) : $this->session->userdata('uid') ?></dd>
<dt>Username</dt>
<dd><?= $user ?></dd>
<dt>Email</dt>
<dd><?= $email ?></dd>
<dt>Timezone</dt>
<dd>
<select id="timezone" name="timezone">
<?php
$continent = '';
$timezone_identifiers = DateTimeZone::listIdentifiers();
foreach( $timezone_identifiers as $value ){
if ( preg_match( '/^(America|Asia|Atlantic|Europe|Indian|Pacific)\//', $value ) ){
$ex=explode("/",$value);//obtain continent,city
if ($continent!=$ex[0]){
if ($continent!="") ?></optgroup><?php
?><optgroup label="<?=$ex[0]?>"><?php
}
$city=$ex[1];
$city .= (isset($ex[2])) ? "/".$ex[2] : "";
$continent=$ex[0];
?><option <?= ($value == $timezone) ? 'selected="selected"' : "";?> value="<?=$value?>"><?= $city ?></option><?php
}
}
?>
</optgroup>
</select>
</dd>
<dt>Id Number Format</dt>
<dd>
<select name="num_format" id="num_format">
<option value="0" <?= ($num_format == 0) ? 'selected="selected"' : '' ?>>Arabic (1,2,3)</option>
<option value="1" <?= ($num_format == 1) ? 'selected="selected"' : '' ?>>Chinese (一,二,三)</option>
<option value="-1" <?= ($num_format == -1) ? 'selected="selected"' : '' ?>>Hide Ids</option>
</select>
</dd>
</dl>
</section>

28
application/views/footer.php Executable file
View File

@ -0,0 +1,28 @@
</div>
<?php $q_num = $this->page->num_queries() ?>
<hr />
<footer class="footer">
Generated in <?= $this->benchmark->elapsed_time();?> seconds, <?= $q_num ?> quer<?= ($q_num == 1) ? "y": "ies" ?>
</footer>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://static.timshomepage.net/piwik/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="http://static.timshomepage.net/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Code -->
<?php if($this->session->userdata('uid') == 1){$this->output->enable_profiler(TRUE);} ?>
<script src="/js/jquery.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<?= $foot_js ?>
</body>
</html>

View File

@ -0,0 +1,13 @@
<?php $i=0 ?>
<tbody>
<?php if(is_array($results)) : ?>
<?php foreach ($results as $result): ?>
<tr class="<?= ($i%2 != 0 ) ? 'alt ' : "";?>">
<td><input type="button" value="Send Friend Request" id="f_<?= $result['id'] ?>" class="request_sub" /></td>
<td><?= $result['username'] ?></td>
<td><?= $result['email'] ?></td>
</tr>
<?php $i++ ?>
<?php endforeach; ?>
<?php endif ?>
</tbody>

View File

@ -0,0 +1,46 @@
<?php $this->load->view('friend/side_nav'); ?>
<section class="right">
<?php if($this->session->userdata('username') !== 'guest'): ?>
<form action="<?= site_url('group/add_sub');?>" method="post">
<fieldset>
<legend>Add Group</legend>
<dl>
<dt><label for="name">Name</label></dt>
<dd>
<input type="text" name="name" id="name" value="" placeholder="Group Name" />
</dd>
<dt>&nbsp;</dt>
<dd><input type="submit" name="add_sub" value="Add Group" /></dd>
</dl>
</fieldset>
</form>
<?php endif ?>
<table class="rowstyle-alt">
<caption>Your Groups</caption>
<thead>
<tr>
<th class="sortable">Name</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php if(is_array($group)): ?>
<?php foreach ($group as $c): ?>
<tr <?= ($i%2 != 0 ) ? 'class="alt"' : "";?>>
<td><span class="icon edit"></span><a href="<?= site_url('group/manage/' . $c['id']) ?>"><?= $c['name'] ?></a></td>
<td>
<input type="button" class="del_group" id="group_<?= $c['id'] ?>" value="Delete Group" />
</td>
</tr>
<?php $i++?>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td>You don't have any friend groups</td>
</tr>
<?php endif ?>
</tbody>
</table>
</section>

View File

@ -0,0 +1,30 @@
<?php $this->load->view('friend/side_nav'); ?>
<section id="task_list" class="right">
<?php if(is_array($friend_list)): ?>
<table class="rowstyle-alt">
<caption>Friends</caption>
<thead>
<tr>
<th class="sortable">Username</th>
<th class="sortable">Email</th>
<th class="sortable">Groups</th>
</tr>
</thead>
<tbody>
<?php $i = 0 ?>
<?php foreach ($friend_list as $friend): ?>
<tr class="<?= ($i%2 != 0 ) ? 'alt ' : "";?>">
<td><?= $friend['username'] ?></td>
<td><?= $friend['email'] ?></td>
<td><?= implode(', ', (array)$friend['groups']) ?></td>
</tr>
<?php $i++ ?>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<h1>Friends</h1>
<p>You currently have no friends :(</p>
<?php endif; ?>
</section>

View File

@ -0,0 +1,31 @@
<?php $this->load->view('friend/side_nav'); ?>
<?php $uid = $this->session->userdata('uid'); ?>
<?php $group_id = $this->uri->segment('3'); ?>
<section class="right">
<h1>Manage Group</h1>
<form action="<?= site_url("group/manage") .'/'. $group_id ?>" method="post">
<fieldset>
<legend>Group Members</legend>
<dl>
<dt><label for="group_name">Group Name:</label></dt>
<dd>
<input type="text" name="group_name" id="group_name" value="<?= $group_name ?>" size="10" />
</dd>
<dt><label for="friends">Friends in group:</label></dt>
<dd>
<select multiple="multiple" size="10" name="friends[]" id="friends">
<?php if(is_array($friends)): ?>
<?php foreach($friends as $friend) : ?>
<?php $option_value = ($friend['uid'] == $uid) ? $friend['user_friend_id'] : $friend['uid'] ?>
<option value="<?= $option_value ?>" <?= (in_array($option_value, $selected_friends)) ? 'selected="selected"' : '' ?>><?= $friend['username'] ?></option>
<?php endforeach; ?>
<?php endif ?>
<option value="">&nbsp;</option>
</select>
</dd>
<dt>&nbsp;</dt>
<dd><input type="submit" name="group_sub" value="Save Changes" /></dd>
</dl>
</fieldset>
</form>
</section>

View File

@ -0,0 +1,33 @@
<?php $this->load->view('friend/side_nav'); ?>
<section id="task_list" class="right">
<?php if(is_array($request_list)): ?>
<table class="rowstyle-alt">
<caption>Friend Requests</caption>
<thead>
<tr>
<th class="sortable">Username</th>
<th class="sortable">Email</th>
<th class="sortable">Accept/Reject</th>
</tr>
</thead>
<tbody>
<?php $i = 0 ?>
<?php foreach ($request_list as $request): ?>
<tr class="<?= ($i%2 != 0 ) ? 'alt ' : "";?>">
<td><?= $request['username'] ?></td>
<td><?= $request['email'] ?></td>
<td>
<input type="button" class="accept_request" id="af_<?= $request['user_id'] ?>" value="Accept Friend Request" />
<input type="button" class="reject_request" id="rf_<?= $request['user_id'] ?>" value="Reject Friend Request" />
</td>
</tr>
<?php $i++ ?>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<h1>Friend Requests</h1>
<p>You currently have no requests.</p>
<?php endif; ?>
</section>

View File

@ -0,0 +1,24 @@
<?php $this->load->view('friend/side_nav'); ?>
<section class="right">
<form action="#" method="post">
<fieldset>
<legend>Find Friends</legend>
<dl>
<dt><label for="q">Username/Email:</label></dt>
<dd><input type="text" name="q" id="q" placeholder="Search by email or username" size="40" /></dd>
<!--<dt>&nbsp;</dt>
<dd><input type="submit" name="friend_search" value="Search" /></dd>-->
</dl>
</fieldset>
</form>
<table id="friend_search_results">
<thead>
<tr>
<th>&nbsp;</th>
<th class="sortable">Username</th>
<th class="sortable">Email</th>
</tr>
</thead>
<tbody></tbody>
</table>
</section>

View File

@ -0,0 +1,36 @@
<?php if(isset($err)): ?>
<?php if(is_array($err)) : ?>
<div class="err_wrap">
Fix the following errors:
<?php foreach ($err as $e): ?>
<p class="error"><?= $e ?></p>
<?php endforeach;?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php $link = $this->uri->segment(2) ?>
<aside id="left_nav" class="left">
<nav>
<ul>
<li <?= ($link == "" || $link == "list") ? 'class="active"' : "";?>>
<span class="icon status_online"></span>
<a href="<?= site_url('friend/list')?>">Your Friends</a>
</li>
<li <?= ($link == "find") ? 'class="active"' : "";?>>
<span class="icon search"></span>
<a href="<?= site_url('friend/find')?>">Find Friends</a>
</li>
<li <?= ($link == "requests") ? 'class="active"' : "";?>>
<span class="icon user_comment"></span>
<a href="<?= site_url('friend/requests')?>">Friend Requests</a>
<?php if($this->todo->get_friend_requests() > 0): ?>
<span id="side_num_requests"><?= $this->todo->get_friend_requests() ?></span>
<?php endif; ?>
</li>
<li <?= ($link == "manage") ? 'class="active"' : "";?>>
<span class="icon group"></span>
<a href="<?= site_url('group/manage')?>">Friend Groups</a>
</li>
</ul>
</nav>
</aside>

10
application/views/header.php Executable file
View File

@ -0,0 +1,10 @@
<head>
<?= $meta ?>
<link rel="icon" href="//todo.timshomepage.net/images/favicon.ico" type="image/x-icon" />
<?= $css ?>
<title><?= $title ?></title>
<?= $head_js ?>
</head>
<body <?= (!empty($body_id)) ? " id=\"" . $body_id . "\"" : ""; ?>>
<?php $this->load->view('menu') ?>

View File

@ -0,0 +1,49 @@
<?php if( ! empty($err)) : ?>
<div class="err_wrap">
Fix the following errors:
<?php foreach ($err as $e): ?>
<p class="error"><?= $e ?></p>
<?php endforeach;?>
</div>
<?php endif; ?>
<section class="left">
<h1>What is Tim's Todo?</h1>
<p>Tim's Todo is a task manager that allows you to...</p>
<ul class="bulleted">
<li>Create, edit, and categorize tasks</li>
<li>Send email reminders that a task is due</li>
<li>Share tasks with friends</li>
<li>Create task checklists</li>
<li>Comment on your tasks, and those shared with you</li>
</ul>
<p>If it sounds interesting, or useful, sign up and try it out.</p>
<p><strong>Want to try it without creating an account? Login with username: <em>guest</em> and password: <em>guest</em></strong></p>
<p>It's nice to have feedback. Send suggestions/comments/criticism to <a href="mailto:tim@timshomepage.net?subject=Tim's Todo Feedback">tim (at) timshomepage.net</a> or <a href="http://twitter.com/timw4mail">@timw4mail</a> on Twitter.</p>
</section>
<section class="right">
<?= form_open('login') ?>
<fieldset>
<legend>Login</legend>
<dl>
<dt><label for="user">Email or Username:</label></dt>
<dd>
<input type="text" name="user" id="user"
required="required" value="" size="10" />
</dd>
<dt><label for="pass">Password:</label></dt>
<dd>
<input type="password" name="pass" id="pass"
required="required" value="" size="10" />
</dd>
<dt>&nbsp;</dt>
<dd>
<input type="submit" name="login_sub" value="Login" />
</dd>
</dl>
</fieldset>
</form>
<br />
<br />
Don't have an account? <a href="<?=site_url('register');?>">Register</a>
</section>

View File

@ -0,0 +1,42 @@
<?php if(is_array($err)) : ?>
<div class="err_wrap">
Fix the following errors:
<?php foreach ($err as $e): ?>
<p class="error"><?= $e ?></p>
<?php endforeach;?>
</div>
<?php endif; ?>
<section class="left">
Already have an account? <a href="<?=site_url('login')?>">Login</a>
</section>
<section class="right">
<?= form_open('register') ?>
<fieldset>
<legend>Create an account</legend>
<dl>
<dt><label for="user">Username:</label></dt>
<dd>
<input type="text" name="user" id="user"
required="required" value="<?= set_value('user') ?>" size="10" />
</dd>
<dt><label for="pass">Password:</label></dt>
<dd>
<input type="password" name="pass" id="pass"
required="required" value="" size="10" />
<input type="password" name="pass1" id="pass1"
required="required" value="" size="10" />
</dd>
<dt><label for="email">Email:</label></dt>
<dd>
<input type="email" name="email" id="email"
required="required" value="<?= set_value('email') ?>" size="10" />
</dd>
<dt>&nbsp;</dt>
<dd>
<input type="submit" name="reg_sub" value="Register" />
</dd>
</dl>
</fieldset>
</form>
</section>

39
application/views/menu.php Executable file
View File

@ -0,0 +1,39 @@
<header>
<figure class="left">
<img src="/images/todo.png" alt="Tim's ToDo" id="bannerImg" height="34" />
<figcaption style="display:none;">Tim's Todo</figcaption>
</figure>
<?php if ($this->session->userdata('uid') != FALSE): ?>
<nav id="header_nav" class="right">
<ul>
<li <?= ($this->uri->segment('1') == 'task') ? 'class="active"' : "";?>>
<a href="<?= site_url('task/list');?>">Tasks</a>
</li>
<li <?= ($this->uri->segment('1') == 'account') ? 'class="active"' : "";?>>
<a href="<?=site_url('account');?>">Account</a>
</li>
<li <?= ($this->uri->segment('1') == 'friend') ? 'class="active"' : "";?>>
<a href="<?= site_url('friend/list');?>">Friends</a>
<?php if($this->todo->get_friend_requests() > 0): ?>
<span id="num_requests"><?= $this->todo->get_friend_requests() ?></span>
<?php endif; ?>
</li>
<li><a href="<?= site_url('logout');?>">Logout</a></li>
</ul>
</nav>
<?php endif; ?>
</header>
<?php if(isset($err)): ?>
<?php if(is_array($err)) : ?>
<div class="err_wrap">
Fix the following errors:
<?php foreach ($err as $e): ?>
<p class="error"><?= $e ?></p>
<?php endforeach;?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if($this->session->flashdata('message') != FALSE): ?>
<?= $this->page->set_message($this->session->flashdata('message_type'), $this->session->flashdata('message'), TRUE); ?>
<?php endif ?>
<div class="wrap">

4
application/views/message.php Executable file
View File

@ -0,0 +1,4 @@
<div class="message <?= $stat_type ?>">
<span class="icon <?= $stat_type ?>"></span>
<?= $message ?><span class="icon close" onclick="this.parentElement.style.display='none'"></span>
</div>

165
application/views/task/add.php Executable file
View File

@ -0,0 +1,165 @@
<?php $this->load->view('task/side_nav'); ?>
<section id="task_add" class="right">
<h1>Add Task</h1>
<?= form_open('task/add') ?>
<fieldset>
<legend>Task</legend>
<dl>
<dt><label for="title">Title</label></dt>
<dd>
<input type="text" name="title" id="title" value="<?= $title ?>" placeholder="Task Heading" />
</dd>
<dt><label for="desc">Description</label></dt>
<dd>
<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= $description ?></textarea>
</dd>
<dt><label for="category">Category</label></dt>
<dd>
<select name="category" id="category">
<option>&nbsp;</option>
<?= $cat_list ?>
</select>
</dd>
<dt><label for="priority">Priority</label></dt>
<dd>
<select name="priority" id="priority">
<?= $pri_list ?>
</select>
</dd>
<dt><label for="due">Due date [YYYY-MM-DD] (0&nbsp;is no due date)</label></dt>
<dd>
<input type="text" name="due" id="due" value="<?= date('Y-m-d', $due) ?>" placeholder="YYYY-MM-DD" size="10" />
<label>Hour:
<select name="due_hour">
<option value="00"<?= (date('H', $due) == 00) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 01) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 02) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 03) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 04) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 05) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 06) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 07) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 08) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 09) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option>
<option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option>
<option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option>
<option value="13"<?= (date('H', $due) == 13) ? ' selected="selected"' : "" ?>>1 PM</option>
<option value="14"<?= (date('H', $due) == 14) ? ' selected="selected"' : "" ?>>2 PM</option>
<option value="15"<?= (date('H', $due) == 15) ? ' selected="selected"' : "" ?>>3 PM</option>
<option value="16"<?= (date('H', $due) == 16) ? ' selected="selected"' : "" ?>>4 PM</option>
<option value="17"<?= (date('H', $due) == 17) ? ' selected="selected"' : "" ?>>5 PM</option>
<option value="18"<?= (date('H', $due) == 18) ? ' selected="selected"' : "" ?>>6 PM</option>
<option value="19"<?= (date('H', $due) == 19) ? ' selected="selected"' : "" ?>>7 PM</option>
<option value="20"<?= (date('H', $due) == 20) ? ' selected="selected"' : "" ?>>8 PM</option>
<option value="21"<?= (date('H', $due) == 21) ? ' selected="selected"' : "" ?>>9 PM</option>
<option value="22"<?= (date('H', $due) == 22) ? ' selected="selected"' : "" ?>>10 PM</option>
<option value="23"<?= (date('H', $due) == 23) ? ' selected="selected"' : "" ?>>11 PM</option>
</select>
</label>
<label> Minute:<input type="text" name="due_minute" id="due_minute" value="<?= date('i', $due) ?>" size="2" /></label>
</dd>
<dt><label for="reminder">Email Reminder</label></dt>
<dd><input type="checkbox" name="reminder" id="reminder" value="rem_true" <?= ($reminder == TRUE) ? 'checked="checked"': '';?> /></dd>
<dt>&nbsp;</dt>
<dd id="reminder_form">
<label for="rem_hours">Hours</label>:<input type="text" name="rem_hours" id="rem_hours" size="2" value="<?= $rem_hours ?>" />
<label for="rem_minutes">Minutes</label>:<input type="text" name="rem_minutes" id="rem_minutes" size="2" value="<?= $rem_minutes ?>" />
before the task is due.
</dd>
</dl>
</fieldset>
<fieldset>
<legend>Task Permissions</legend>
<dl>
<dt><label for="share">Share this task</label></dt>
<dd><input type="checkbox" name="share" id="share" /></dd>
</dl>
<dl id="share_form">
<dt>Share with:</dt>
<dd>
<label for="friend_share">Individual Friends</label>
<input type="radio" name="share_type" value="friend" id="friend_share" />
&nbsp;
&nbsp;
<label for="group_share">Groups of Friends</label>
<input type="radio" name="share_type" value="group" id="group_share" />
</dd>
<?php if(is_array($friends)): ?>
<dt class="friend_share"><strong>Friend Settings</strong></dt>
<dd class="friend_share">
<dl>
<dt><label for="friend">Friends</label></dt>
<dd>
<select name="friend[]" id="group" multiple="multiple" size="5">
<?php foreach ($friends as $friend): ?>
<?php $uid = $this->session->userdata('uid'); ?>
<?php $option_value = ($friend['uid'] == $uid) ? $friend['user_friend_id'] : $friend['uid'] ?>
<option value="<?= $option_value ?>"><?= $friend['username'] ?></option>
<?php endforeach ?>
</select>
</dd>
<dt><label for="friend_perms">Permissions</label></dt>
<dd>
<select name="friend_perms" id="friend_perms">
<option value="-1">No Access</option>
<option value="0">Read-only Access</option>
<option value="1">Comment-only Access</option>
<option value="2">Comment and Checklist Access</option>
<option value="3">Read and Write Access</option>
<option value="9">Task Admin (Read/Write/Delete)</option>
</select>
</dd>
</dl>
</dd>
<?php else: ?>
<dd class="friend_share">
You don't currently have any friends :(
</dd>
<?php endif ?>
<?php if(is_array($groups)): ?>
<dt class="group_share"><strong>Group-wide Settings</strong></dt>
<dd class="group_share">
<dl>
<dt><label for="group">Groups</label></dt>
<dd>
<select name="group[]" id="group" multiple="multiple" size="5">
<?php foreach ($groups as $group): ?>
<option value="<?= $group['id'] ?>"><?= $group['name'] ?></option>
<?php endforeach ?>
</select>
</dd>
<dt><label for="group_perms">Permissions</label></dt>
<dd>
<select name="group_perms" id="group_perms">
<option value="-1">No Access</option>
<option value="0">Read-only Access</option>
<option value="1">Comment-only Access</option>
<option value="2">Comment and Checklist Access</option>
<option value="3">Read and Write Access</option>
<option value="9">Task Admin (Read/Write/Delete)</option>
</select>
</dd>
</dl>
</dd>
<?php else: ?>
<dd class="group_share">
You need to create <a href="<?= site_url('friend/group/add') ?>">friend groups</a> before you can share tasks.
</dd>
<?php endif ?>
</dl>
</fieldset>
<fieldset>
<dl>
<dt>&nbsp;</dt>
<dd>
<input type="submit" name="add_sub" value="Add Task" />
</dd>
</dl>
</fieldset>
</form>
</section>

View File

@ -0,0 +1,5 @@
<li>
<input type="checkbox" name="checklist[]" value="<?= $id ?>" id="check_<?= $id?>" <?= ($is_checked == 1) ? 'checked="checked"' : '' ?> />
&nbsp;&nbsp;<label for="check_<?= $id ?>"><?= $desc ?></label>
</li>

View File

@ -0,0 +1,33 @@
<?php $this->load->view('task/side_nav'); ?>
<?php $y = $this->uri->segment(3);
$m = $this->uri->segment(4);
$next = ($this->uri->segment(4) == FALSE) ? $this->calendar->adjust_date(date('m') + 1, date('Y')) :
$this->calendar->adjust_date($m + 1, $y);
$prev = ($this->uri->segment(4) == FALSE) ? $this->calendar->adjust_date(date('m') - 1, date('Y')) :
$this->calendar->adjust_date($m - 1, $y); ?>
<section id="task_view" class="right">
<h1>Task Calendar</h1>
<p>Today is <?= date("l, F d, Y") ?><br />
<a href="<?= site_url('task/calendar/'.$prev['year'].'/'.$prev['month']); ?>">&laquo; Previous Month</a>&nbsp;&nbsp;
<a href="<?= site_url('task/calendar/'.$next['year'].'/'.$next['month']); ?>">Next Month &raquo;</a>
</p>
<table id="task_calendar">
<caption><?= $month ?>
</caption>
<thead>
<tr>
<th>Sunday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>
</thead>
<tbody>
<?= $calendar ?>
</tbody>
</table>
</section>

View File

@ -0,0 +1,25 @@
<?php $this->load->view('task/side_nav'); ?>
<section id="task_add" class="right">
<form action="<?= site_url('category/edit_sub');?>" method="post">
<fieldset>
<legend>Edit Category</legend>
<dl>
<dt><label for="title">Title</label></dt>
<dd>
<input type="text" name="title" id="title" value="<?= $cat['title'] ?>" placeholder="Category Heading" />
<input type="hidden" value="<?= $this->uri->segment('4') ?>" name="id" />
</dd>
<dt><label for="desc">Description</label></dt>
<dd>
<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Category details">
<?= $cat['description'] ?>
</textarea>
</dd>
<dt>&nbsp;</dt>
<dd><input type="submit" name="edit_sub" value="Save Changes" /></dd>
</dl>
</fieldset>
</form>
</section>

View File

@ -0,0 +1,64 @@
<?php $this->load->view('task/side_nav'); ?>
<section class="right">
<form action="<?= site_url('category/add_sub');?>" method="post">
<fieldset>
<legend>Add Category</legend>
<dl>
<dt><label for="title">Title</label></dt>
<dd>
<input type="text" name="title" id="title" value="" placeholder="Category Heading" />
</dd>
<dt><label for="desc">Description</label></dt>
<dd>
<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Category details"></textarea>
</dd>
<dt>&nbsp;</dt>
<dd><input type="submit" name="add_sub" value="Add Category" /></dd>
</dl>
</fieldset>
</form>
<table class="rowstyle-alt">
<caption>Categories</caption>
<thead>
<tr>
<?php if($this->session->userdata('num_format') != -1): ?>
<th class="sortable">ID</th>
<?php endif ?>
<th class="sortable">Name</th>
<th class="sortable">Description</th>
<th>&nbsp;</th>
<th class="sortable">Type</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php foreach ($category as $c): ?>
<tr <?= ($i%2 != 0 ) ? 'class="alt"' : "";?>>
<?php if($this->session->userdata('num_format') != -1): ?>
<td class="id"><?= ($this->session->userdata('num_format') == 1) ? $this->todo->kanji_num($c['id']) : $c['id']; ?></td>
<?php endif ?>
<td>
<?php if($c['group_id'] != 0): ?>
<a class="edit" href="<?= site_url('category/edit/'. $c['id']) ?>"><?= $c['title'] ?></a>
<?php else: ?>
<?= $c['title'] ?>
<?php endif ?>
</td>
<td><?= $c['description'] ?></td>
<td>
<?php if($c['group_id'] != 0): ?>
<input type="button" class="del_cat" id="cat_<?=$c['id']?>" value="Delete Category" />
<?php else: ?>
&nbsp;
<?php endif ?>
</td>
<td><?= ($c['group_id'] == 0) ? "Public" : "Private"; ?></td>
</tr>
<?php $i++?>
<?php endforeach; ?>
</tbody>
</table>
</section>

View File

@ -0,0 +1,15 @@
<section id="task_checklist">
<ul id="checklist">
<?php $i=0; ?>
<?php if(!empty($checklist)) : ?>
<?php foreach($checklist as $c) : ?>
<li>
<input type="checkbox" name="checklist[]" value="<?= $c['id'] ?>" id="check_<?= $c['id']?>" <?= ($c['is_checked']== 1) ? 'checked="checked"' : '' ?> <?= ($user_perms <= PERM_CHECKLIST_ACCESS) ? 'disabled="disabled"' : '' ?> />
&nbsp;&nbsp;<label for="check_<?= $c['id']?>"><?= $c['desc'] ?></label>
</li>
<?php endforeach ?>
<?php endif ?>
</ul>
</section>

View File

@ -0,0 +1,21 @@
<section id="task_comment_list">
<?php $i=0; ?>
<?php if(!empty($comments)) : ?>
<?php foreach($comments as $c) : ?>
<dl id="comment_<?= $c['id']?>"<?= ($i%2 != 0 ) ? 'class="alt"' : "";?>>
<dt ><?= $c['email']?><br /><?= date('D M d, Y g:iA T', $c['time_posted']);?><br />(<?= $c['status'] ?>)</dt>
<dd>
<?php if($c['user_id'] == $this->session->userdata('uid')): ?>
<span class="editComment">
<a href="#" class="delete comment_del">Delete</a>
</span>
<?php endif ?>
<div class="comment_text"><?= $c['comment'] ?></div>
<div class="clearB"></div>
</dd>
<?php $i++ ?>
</dl>
<?php endforeach ?>
<?php endif; ?>
</section>

211
application/views/task/edit.php Executable file
View File

@ -0,0 +1,211 @@
<?php $this->load->view('task/side_nav'); ?>
<section id="task_add" class="right">
<h1>Edit Task</h1>
<?php if($user_perms == PERM_ADMIN_ACCESS): ?>
<p id="delTask"><a href="#" onclick="if(confirm('Are you sure you want to delete this task')){window.location='<?= site_url('task/delete').'/'.$this->security->xss_clean($this->uri->segment('3')) ?>'}">Delete Task</a></p>
<?php endif ?>
<?= form_open('task/edit' . '/' . $this->uri->segment(3)); ?>
<fieldset>
<legend>Task</legend>
<dl>
<dt><label for="title">Title</label></dt>
<dd>
<input type="text" name="title" id="title" value="<?= $title ?>" placeholder="Task Heading" />
</dd>
<dt><label for="desc">Description</label></dt>
<dd>
<textarea rows="10" cols="80" name="desc" id="desc" placeholder="Task details"><?= $description ?></textarea>
</dd>
<dt><label for="category">Category</label></dt>
<dd>
<select name="category" id="category">
<?= $cat_list ?>
</select>
</dd>
<dt><label for="priority">Priority</label></dt>
<dd>
<select name="priority" id="priority">
<?= $pri_list ?>
</select>
</dd>
<dt><label for="status">Status</label></dt>
<dd>
<select name="status" id="status">
<?= $stat_list ?>
</select>
</dd>
<dt><label for="due">Due date [YYYY-MM-DD] (0 is no due date)</label></dt>
<dd>
<input type="text" name="due" id="due" value="<?= ($due != 0) ? date('Y-m-d', $due) : 0 ?>" placeholder="YYYY-MM-DD" size="10" />
<label>Hour:
<select name="due_hour">
<option value="00"<?= (date('H', $due) == 00) ? ' selected="selected"' : "" ?>>Midnight</option>
<option value="01"<?= (date('H', $due) == 01) ? ' selected="selected"' : "" ?>>1 AM</option>
<option value="02"<?= (date('H', $due) == 02) ? ' selected="selected"' : "" ?>>2 AM</option>
<option value="03"<?= (date('H', $due) == 03) ? ' selected="selected"' : "" ?>>3 AM</option>
<option value="04"<?= (date('H', $due) == 04) ? ' selected="selected"' : "" ?>>4 AM</option>
<option value="05"<?= (date('H', $due) == 05) ? ' selected="selected"' : "" ?>>5 AM</option>
<option value="06"<?= (date('H', $due) == 06) ? ' selected="selected"' : "" ?>>6 AM</option>
<option value="07"<?= (date('H', $due) == 07) ? ' selected="selected"' : "" ?>>7 AM</option>
<option value="08"<?= (date('H', $due) == 08) ? ' selected="selected"' : "" ?>>8 AM</option>
<option value="09"<?= (date('H', $due) == 09) ? ' selected="selected"' : "" ?>>9 AM</option>
<option value="10"<?= (date('H', $due) == 10) ? ' selected="selected"' : "" ?>>10 AM</option>
<option value="11"<?= (date('H', $due) == 11) ? ' selected="selected"' : "" ?>>11 AM</option>
<option value="12"<?= (date('H', $due) == 12) ? ' selected="selected"' : "" ?>>12 Noon</option>
<option value="13"<?= (date('H', $due) == 13) ? ' selected="selected"' : "" ?>>1 PM</option>
<option value="14"<?= (date('H', $due) == 14) ? ' selected="selected"' : "" ?>>2 PM</option>
<option value="15"<?= (date('H', $due) == 15) ? ' selected="selected"' : "" ?>>3 PM</option>
<option value="16"<?= (date('H', $due) == 16) ? ' selected="selected"' : "" ?>>4 PM</option>
<option value="17"<?= (date('H', $due) == 17) ? ' selected="selected"' : "" ?>>5 PM</option>
<option value="18"<?= (date('H', $due) == 18) ? ' selected="selected"' : "" ?>>6 PM</option>
<option value="19"<?= (date('H', $due) == 19) ? ' selected="selected"' : "" ?>>7 PM</option>
<option value="20"<?= (date('H', $due) == 20) ? ' selected="selected"' : "" ?>>8 PM</option>
<option value="21"<?= (date('H', $due) == 21) ? ' selected="selected"' : "" ?>>9 PM</option>
<option value="22"<?= (date('H', $due) == 22) ? ' selected="selected"' : "" ?>>10 PM</option>
<option value="23"<?= (date('H', $due) == 23) ? ' selected="selected"' : "" ?>>11 PM</option>
</select>
</label>
<label> Minute:<input type="text" name="due_minute" id="due_minute" value="<?= date('i', $due)?>" size="2" /></label>
</dd>
<dt><label for="reminder">Email Reminder</label></dt>
<dd><input type="checkbox" name="reminder" id="reminder" value="rem_true" <?= ($reminder == TRUE) ? 'checked="checked"': '';?> /></dd>
<dt>&nbsp;</dt>
<dd id="reminder_form">
<label for="rem_hours">Hours</label>:<input type="text" name="rem_hours" id="rem_hours" size="2" value="<?= $rem_hours ?>" />
<label for="rem_minutes">Minutes</label>:<input type="text" name="rem_minutes" id="rem_minutes" size="2" value="<?= $rem_minutes ?>" />
before the task is due.
</dd>
</dl>
</fieldset>
<fieldset>
<legend>Task Permissions</legend>
<dl>
<dt><label for="share">Share this task</label></dt>
<dd><input type="checkbox" name="share" id="share" <?= ( ! empty($selected_groups) || ! empty($selected_friends)) ? 'checked="checked"' : '' ?> /></dd>
</dl>
<dl id="share_form">
<dt>Share with:</dt>
<dd>
<label for="friend_share">Individual Friends</label>
<input type="radio" name="share_type" value="friend" id="friend_share" <?= (empty($selected_friends)) ? "": 'checked="checked"' ?>/>
&nbsp;
&nbsp;
<label for="group_share">Groups of Friends</label>
<input type="radio" name="share_type" value="group" id="group_share" <?= (empty($selected_groups)) ? "": 'checked="checked"' ?> />
</dd>
<?php if( ! empty($friends)): ?>
<?php if($selected_friends === FALSE) {$selected_friends = array();} ?>
<dt class="friend_share"><strong>Friend Settings</strong></dt>
<dd class="friend_share">
<dl>
<dt><label for="friend">Friends</label></dt>
<dd>
<select name="friend[]" id="friend" multiple="multiple" size="5">
<?php foreach ($friends as $friend): ?>
<?php $uid = $this->session->userdata('uid'); ?>
<?php $option_value = ($friend['uid'] == $uid) ? $friend['user_friend_id'] : $friend['uid'] ?>
<option value="<?= $option_value ?>" <?= (in_array($option_value, $selected_friends))?'selected="selected"':''?>><?= $friend['username'] ?></option>
<?php endforeach ?>
</select>
</dd>
<dt><label for="friend_perms">Permissions</label></dt>
<dd>
<select name="friend_perms" id="friend_perms">
<option value="-1" <?= ($friend_perms === PERM_NO_ACCESS) ? 'selected="selected"':''?>>No Access</option>
<option value="0" <?= ($friend_perms === PERM_READ_ACCESS) ? 'selected="selected"':''?>>Read-only Access</option>
<option value="1" <?= ($friend_perms === PERM_COMMENT_ACCESS) ? 'selected="selected"':''?>>Comment-only Access</option>
<option value="2" <?= ($friend_perms === PERM_CHECKLIST_ACCESS) ? 'selected="selected"':''?>>Comment and Checklist Access</option>
<option value="3" <?= ($friend_perms === PERM_WRITE_ACCESS) ? 'selected="selected"':''?>>Read and Write Access</option>
<option value="9" <?= ($friend_perms === PERM_ADMIN_ACCESS) ? 'selected="selected"':''?>>Task Admin (Read/Write/Delete)</option>
</select>
</dd>
</dl>
</dd>
<?php else: ?>
<dd class="friend_share">
You don't currently have any friends :(
</dd>
<?php endif ?>
<?php if( ! empty($groups)): ?>
<?php if( ! is_array($selected_groups)) $selected_groups = array(); ?>
<dt class="group_share"><strong>Group-wide Settings</strong></dt>
<dd class="group_share">
<dl>
<dt><label for="group">Groups</label></dt>
<dd>
<select name="group[]" id="group" multiple="multiple" size="5">
<?php foreach ($groups as $group): ?>
<option value="<?= $group['id'] ?>" <?= (in_array($group['id'], $selected_groups))?'selected="selected"':''?>><?= $group['name'] ?></option>
<?php endforeach ?>
</select>
</dd>
<dt><label for="group_perms">Permissions</label></dt>
<dd>
<select name="group_perms" id="group_perms">
<option value="-1" <?= ($group_perms == "-1") ? 'selected="selected"':''?>>No Access</option>
<option value="0" <?= ($group_perms == "0") ? 'selected="selected"':''?>>Read-only Access</option>
<option value="1" <?= ($group_perms == "1") ? 'selected="selected"':''?>>Comment-only Access</option>
<option value="2" <?= ($group_perms == "2") ? 'selected="selected"':''?>>Comment and Checklist Access</option>
<option value="3" <?= ($group_perms == "3") ? 'selected="selected"':''?>>Read and Write Access</option>
<option value="9" <?= ($group_perms == "4") ? 'selected="selected"':''?>>Task Admin (Read/Write/Delete)</option>
</select>
</dd>
</dl>
</dd>
<?php else: ?>
<dd class="group_share">
You need to create <a href="<?= site_url('friend/group/add') ?>">friend groups</a> before you can share tasks.
</dd>
<?php endif ?>
</dl>
</fieldset>
<fieldset>
<dl>
<dt>&nbsp;</dt>
<dd>
<input type="hidden" name="task_id" value="<?= $this->uri->segment($this->uri->total_segments()) ?>" id="task_id" />
<input type="submit" name="edit_sub" value="Update Task" />
</dd>
</dl>
</fieldset>
</form>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Checklist</a></li>
<li><a href="#tabs-2">Comments</a></li>
</ul>
<div id="tabs-1">
<span id="toggle_checklist" class="add">Add Checklist item</span>
<dl id="add_checklist_dl">
<dt>&nbsp;</dt>
<dd id="ajax_status">&nbsp;</dd>
<dt><label for="check_desc">Checklist item:</label></dt>
<dd>
<input type="text" size="10" name="check_desc" id="check_desc" />&nbsp;&nbsp;
<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" />
</dd>
</dl>
<?php $this->load->view('task/checklist_view'); ?>
</div>
<div id="tabs-2">
<span id="toggle_comments" class="add">Add Comment</span>
<dl id="add_comment_dl">
<dt>&nbsp;</dt>
<dd id="ajax_status">&nbsp;</dd>
<dt>&nbsp;</dt>
<dd>
<textarea rows="10" cols="80" name="comment" id="comment"></textarea>
<br />
<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" />
</dd>
</dl>
<?php $this->load->view('task/comments_view'); ?>
</div>
</div>
</section>

53
application/views/task/list.php Executable file
View File

@ -0,0 +1,53 @@
<?php $this->load->view('task/side_nav'); ?>
<section id="task_list" class="right">
<?php if(is_array($task_list)): ?>
<table class="rowstyle-alt">
<caption><?= $list_type ?> Tasks</caption>
<thead>
<tr>
<?php if($this->session->userdata('num_format') != -1): ?>
<th class="sortable">Id</th>
<?php endif ?>
<th class="sortable">Task</th>
<th class="sortable">Status</th>
<th class="sortable">Category</th>
<th class="sortable">Priority</th>
<th class="sortable">Due</th>
<th class="sortable"><?= ($this->uri->segment(2) != 'archive') ? "Modified" : "Completed" ?></th>
</tr>
</thead>
<tbody>
<?php $i = 0 ?>
<?php foreach ($task_list as $task): ?>
<?php if (!is_array($task)){continue;} ?>
<tr class="<?= ($i%2 != 0 ) ? 'alt ' : "";?><?= ($task['overdue'] == TRUE) ? 'overdue' : ''?>">
<?php if($this->session->userdata('num_format') != -1): ?>
<td class="id"><?= ($this->session->userdata('num_format') == 1) ? $this->todo->kanji_num($task['id']) : $task['id']; ?></td>
<?php endif ?>
<td class="taskTitle">
<?php if($this->uri->segment(2) != 'archive' && $this->uri->segment(2) != 'shared'): ?>
<a style="float:right;" href="<?= site_url('task/edit') .'/'. $task['id'];?>" title="Edit this task"><img src="/images/icons/pencil.png" alt="Edit" /></a>
<?php endif ?>
<a href="<?= site_url('task/view') .'/'. $task['id'];?>" title="View this task"><?= $task['title']; ?></a>
</td>
<td><?= $task['status']; ?></td>
<td><?= $task['category'] ?></td>
<td class="priority <?= strtolower($task['priority'])?>"><?= $task['priority'] ?></td>
<td><?= ($task['due'] != 0 ) ? date('D M d, Y g:iA', $task['due']) : "N/A" ?></td>
<td><?= ($task['modified'] < 1) ? 'N/A' : date('D M d, Y g:iA', $task['modified']); ?></td>
</tr>
<?php $i++ ?>
<?php endforeach; ?>
</tbody>
</table>
<?php if(isset($pagination) && !empty($pagination)): ?>
<section id="pagination">
<?= $this->pagination->create_links(); ?>
</section>
<?php endif ?>
<?php elseif(count($task_list) < 1): ?>
<h1><?= $list_type ?> Tasks</h1>
<p>You currently have no <?= $list_type ?> tasks.</p>
<?php endif; ?>
</section>

View File

@ -0,0 +1,45 @@
<?php if(isset($err)): ?>
<?php if(is_array($err)) : ?>
<div class="err_wrap">
Fix the following errors:
<?php foreach ($err as $e): ?>
<p class="error"><?= $e ?></p>
<?php endforeach;?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php $link = $this->uri->segment(2) ?>
<aside id="left_nav" class="left">
<nav>
<ul>
<li <?= ($link == "add") ? 'class="active"' : "";?>>
<span class="icon add"></span>
<a href="<?= site_url('task/add')?>">Add Task</a>
</li>
<li <?= ($this->uri->segment(1) == 'task' && $link == "list") ? 'class="active"' : "";?>>
<span class="icon active_tasks"></span>
<a href="<?= site_url('task/list')?>">Active Tasks</a>
</li>
<li <?= ($link == "shared") ? 'class="active"' : "";?>>
<span class="icon group"></span>
<a href="<?= site_url('task/shared') ?>">Shared Tasks</a>
</li>
<li <?= ($link == "overdue") ? 'class="active"' : "";?>>
<span class="icon immediate"></span>
<a href="<?= site_url('task/overdue')?>">Overdue Tasks</a>
</li>
<li <?= ($link == "archive") ? 'class="active"' : "";?>>
<span class="icon archive"></span>
<a href="<?= site_url('task/archive')?>">Archived Tasks</a>
</li>
<li <?= ($link == "calendar") ? 'class="active"' : "";?>>
<span class="icon calendar"></span>
<a href="<?= site_url('task/calendar')?>">Task Calendar</a>
</li>
<li <?= ($this->uri->segment(1) == 'category' && $link == "list") ? 'class="active"' : "";?>>
<psan class="icon cat"></psan>
<a href="<?= site_url('category/list')?>">Task Categories</a>
</li>
</ul>
</nav>
</aside>

113
application/views/task/view.php Executable file
View File

@ -0,0 +1,113 @@
<?php $this->load->view('task/side_nav'); ?>
<section id="task_view" class="right">
<h1><?= $title ?></h1>
<input type="hidden" name="task_id" value="<?= $this->uri->segment($this->uri->total_segments()) ?>" id="task_id" />
<input type="hidden" name="user_perms" value="<?= $user_perms ?>" id="user_perms" />
<?php if($user_perms <= PERM_CHECKLIST_ACCESS): ?>
<input type="hidden" id="status" value="<?= $status_id ?>" />
<?php endif; ?>
<?php if($user_perms > PERM_CHECKLIST_ACCESS): ?>
<p id="editTask">
<?php if($user_perms == PERM_ADMIN_ACCESS){ ?>
<a href="#" id="delTask" onclick="if(confirm('Are you sure you want to delete this task')){window.location='<?= site_url('task/delete').'/'.$this->security->xss_clean($this->uri->segment('3')) ?>'}">Delete Task</a>
<?php } ?>
<a id="editTaskIcon" href="<?= site_url('task/edit').'/'.$task ?>">Edit Task</a>
</p>
<?php endif ?>
<dl>
<dt>Created</dt>
<dd><?= date('D M d, Y g:iA T',$created) ?> by <strong><?= $username ?></strong></dd>
<dt>Due</dt>
<dd><?= ($due != 0 ) ? date('D M d, Y g:iA T', $due) : "N/A"; ?></dd>
<dt>Priority</dt>
<dd>
<span class="priority <?= strtolower($priority) ?>"><?= $priority ?></span>
</dd>
<dt>Status</dt>
<dd>
<?php if($user_perms > PERM_CHECKLIST_ACCESS): ?>
<form action="#" method="post">
<select name="status" id="status">
<?= $status ?>
</select>
</form>
<?php else: ?>
<?= $current_status ?>
<?php endif ?>
</dd>
<dt>Modified</dt>
<dd><?= ($modified < 1) ? 'N/A' : date('D M d, Y g:iA T', $modified); ?></dd>
<dt>Category</dt>
<dd>
<?php if($user_perms > PERM_CHECKLIST_ACCESS): ?>
<form action="#" method="post">
<select name="category" id="category">
<?= $category ?>
</select>
</form>
<?php else: ?>
<?= $cat_name ?>
<?php endif ?>
</dd>
<dt>Task Description</dt>
<dd id="task_desc">
<?= $description ?>
</dd>
<?php if(is_array($selected_groups)): ?>
<dt>Task Groups</dt>
<dd></dd>
<?php endif ?>
</dl>
<?php if($user_perms > PERM_READ_ACCESS): ?>
<div id="tabs">
<ul>
<?php if($user_perms > PERM_COMMENT_ACCESS): ?>
<li><a href="#tabs-1">Checklist</a></li>
<?php endif ?>
<li><a href="#tabs-2">Comments</a></li>
</ul>
<?php if($user_perms > PERM_COMMENT_ACCESS): ?>
<div id="tabs-1">
<?php if ($user_perms > PERM_CHECKLIST_ACCESS): ?>
<span id="toggle_checklist"><span class="icon add"></span>Add Checklist item</span>
<dl id="add_checklist_dl">
<?php /*<dt>&nbsp;</dt>
<dd id="ajax_status">&nbsp;</dd> */ ?>
<dt><label for="check_desc">Checklist item:</label></dt>
<dd>
<input type="text" size="10" name="check_desc" id="check_desc" />&nbsp;&nbsp;
<input type="button" name="add_checklist_item" id="add_checklist_item" value="Add Checklist Item" />
</dd>
</dl>
<?php endif ?>
<?php $this->load->view('task/checklist_view'); ?>
</div>
<?php endif ?>
<div id="tabs-2">
<span id="toggle_comments"><span class="icon add"></span>Add Comment</span>
<dl id="add_comment_dl">
<?php /* <dt>&nbsp;</dt>
<dd id="ajax_status">&nbsp;</dd> */ ?>
<dt>&nbsp;</dt>
<dd>
<textarea rows="10" cols="80" name="comment" id="comment"></textarea>
<br />
<input type="button" name="add_task_comment" id="add_task_comment" value="Submit comment" />
</dd>
</dl>
<?php $this->load->view('task/comments_view'); ?>
</div>
</div>
<?php endif ?>
</section>

Some files were not shown because too many files have changed in this diff Show More