Added based code

Added base code to the repo
This commit is contained in:
Vivek Nair 2024-02-07 20:19:28 +05:30
parent 16ee376793
commit a53135a78d
6812 changed files with 1110905 additions and 0 deletions

2660
advance_school_pro.sql Executable file

File diff suppressed because it is too large Load Diff

6
application/.htaccess Executable file
View File

@ -0,0 +1,6 @@
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>

6
application/cache/.htaccess vendored Executable file
View File

@ -0,0 +1,6 @@
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>

11
application/cache/index.html vendored Executable file
View File

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

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

@ -0,0 +1,16 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$autoload['packages'] = array();
$autoload['libraries'] = array('pagination', 'xmlrpc' , 'form_validation', 'email','upload','paypal');
$autoload['drivers'] = array();
$autoload['helper'] = array('url','file','form','security','string','inflector','directory','download','multi_language');
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array('crud_model');

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

@ -0,0 +1,51 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['base_url'] = '';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'QUERY_STRING';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-=';
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['log_threshold'] = 1;
$config['log_path'] = '/';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = 'Jb5X1q9IAktoEJeDDT2c9J2atEQg6wSC';
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
date_default_timezone_set('America/Guatemala');
$config['csrf_token_name'] = 'webstudiogt';
$config['csrf_cookie_name'] = 'webstudiogt';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';

View File

@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
define('FILE_READ_MODE', 0644);
define('FILE_WRITE_MODE', 0666);
define('DIR_READ_MODE', 0755);
define('DIR_WRITE_MODE', 0755);
define('FOPEN_READ', 'rb');
define('FOPEN_READ_WRITE', 'r+b');
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb');
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b');
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');
define('SHOW_DEBUG_BACKTRACE', TRUE);
define('EXIT_SUCCESS', 0);
define('EXIT_ERROR', 1);
define('EXIT_CONFIG', 3);
define('EXIT_UNKNOWN_FILE', 4);
define('EXIT_UNKNOWN_CLASS', 5);
define('EXIT_UNKNOWN_METHOD', 6);
define('EXIT_USER_INPUT', 7);
define('EXIT_DATABASE', 8);
define('EXIT__AUTO_MIN', 9);
define('EXIT__AUTO_MAX', 125);

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

@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'tameasy_user',
'password' => 'tameasy_user@123',
'database' => 'tameasy_advance_school_pro',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

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

@ -0,0 +1,24 @@
<?php
defined('BASEPATH') OR 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">',
'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">',
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.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">',
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
'xhtml-math-svg-xh' => '<!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">',
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg 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">',
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">'
);

18
application/config/email.php Executable file
View File

@ -0,0 +1,18 @@
<?php if ( ! defined("BASEPATH")) exit("No direct script access allowed");
$config["useragent"] = "CodeIgniter";
$config["protocol"] = "smtp";
$config["smtp_host"] ="ssl://smtp.googlemail.com";
$config["smtp_user"] ="";
$config["smtp_pass"] ="";
$config["smtp_port"] ="465";
$config["smtp_timeout"] ="5";
$config["wordwrap"] = "TRUE";
$config["wrapchars"] = "76";
$config["mailtype"] ="html";
$config["charset"] ="UTF-8";
$config["validate"] = "FALSE";
$config["priority"] = "3";
$config["crlf"] = "\r\n";
$config["newline"]="\r\n";
$config["bcc_batch_mode"] ="FALSE";
$config["bcc_batch_size"] ="200";

View File

@ -0,0 +1,93 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$foreign_characters = array(
'/ä|æ|ǽ/' => 'ae',
'/ö|œ/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A',
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a',
'/Б/' => 'B',
'/б/' => 'b',
'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
'/ç|ć|ĉ|ċ|č/' => 'c',
'/Д/' => 'D',
'/д/' => 'd',
'/Ð|Ď|Đ|Δ/' => 'Dj',
'/ð|ď|đ|δ/' => 'dj',
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E',
'/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e',
'/Ф/' => 'F',
'/ф/' => 'f',
'/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G',
'/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g',
'/Ĥ|Ħ/' => 'H',
'/ĥ|ħ/' => 'h',
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I',
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i',
'/Ĵ/' => 'J',
'/ĵ/' => 'j',
'/Ķ|Κ|К/' => 'K',
'/ķ|κ|к/' => 'k',
'/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L',
'/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l',
'/М/' => 'M',
'/м/' => 'm',
'/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N',
'/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n',
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O',
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o',
'/П/' => 'P',
'/п/' => 'p',
'/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R',
'/ŕ|ŗ|ř|ρ|р/' => 'r',
'/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S',
'/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
'/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T',
'/ț|ţ|ť|ŧ|т/' => 't',
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
'/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
'/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
'/В/' => 'V',
'/в/' => 'v',
'/Ŵ/' => 'W',
'/ŵ/' => 'w',
'/Ź|Ż|Ž|Ζ|З/' => 'Z',
'/ź|ż|ž|ζ|з/' => 'z',
'/Æ|Ǽ/' => 'AE',
'/ß/' => 'ss',
'/IJ/' => 'IJ',
'/ij/' => 'ij',
'/Œ/' => 'OE',
'/ƒ/' => 'f',
'/ξ/' => 'ks',
'/π/' => 'p',
'/β/' => 'v',
'/μ/' => 'm',
'/ψ/' => 'ps',
'/Ё/' => 'Yo',
'/ё/' => 'yo',
'/Є/' => 'Ye',
'/є/' => 'ye',
'/Ї/' => 'Yi',
'/Ж/' => 'Zh',
'/ж/' => 'zh',
'/Х/' => 'Kh',
'/х/' => 'kh',
'/Ц/' => 'Ts',
'/ц/' => 'ts',
'/Ч/' => 'Ch',
'/ч/' => 'ch',
'/Ш/' => 'Sh',
'/ш/' => 'sh',
'/Щ/' => 'Shch',
'/щ/' => 'shch',
'/Ъ|ъ|Ь|ь/' => '',
'/Ю/' => 'Yu',
'/ю/' => 'yu',
'/Я/' => 'Ya',
'/я/' => 'ya'
);

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

@ -0,0 +1,2 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

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

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

View File

@ -0,0 +1,10 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config = array(
'default' => array(
'hostname' => '127.0.0.1',
'port' => '11211',
'weight' => '1',
),
);

View File

@ -0,0 +1,14 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['migration_enabled'] = FALSE;
$config['migration_type'] = 'timestamp';
$config['migration_table'] = 'migrations';
$config['migration_auto_latest'] = FALSE;
$config['migration_version'] = 0;
$config['migration_path'] = APPPATH.'migrations/';

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

@ -0,0 +1,147 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
return array(
'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => array('application/octet-stream', 'application/x-msdownload'),
'class' => 'application/octet-stream',
'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
'ai' => array('application/pdf', 'application/postscript'),
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => array('application/x-javascript', 'text/plain'),
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
'z' => 'application/x-compress',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
'aif' => array('audio/x-aiff', 'audio/aiff'),
'aiff' => array('audio/x-aiff', 'audio/aiff'),
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
'gif' => 'image/gif',
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'png' => array('image/png', 'image/x-png'),
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => array('text/css', 'text/plain'),
'html' => array('text/html', 'text/plain'),
'htm' => array('text/html', 'text/plain'),
'shtml' => array('text/html', 'text/plain'),
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => array('text/plain', 'text/x-log'),
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => array('application/xml', 'text/xml', 'text/plain'),
'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
'movie' => 'video/x-sgi-movie',
'doc' => array('application/msword', 'application/vnd.ms-office'),
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
'dot' => array('application/msword', 'application/vnd.ms-office'),
'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822',
'json' => array('application/json', 'text/json'),
'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
'p10' => array('application/x-pkcs10', 'application/pkcs10'),
'p12' => 'application/x-pkcs12',
'p7a' => 'application/x-pkcs7-signature',
'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
'p7r' => 'application/x-pkcs7-certreqresp',
'p7s' => 'application/pkcs7-signature',
'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
'crl' => array('application/pkix-crl', 'application/pkcs-crl'),
'der' => 'application/x-x509-ca-cert',
'kdb' => 'application/octet-stream',
'pgp' => 'application/pgp',
'gpg' => 'application/gpg-keys',
'sst' => 'application/octet-stream',
'csr' => 'application/octet-stream',
'rsa' => 'application/x-pkcs7',
'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
'3g2' => 'video/3gpp2',
'3gp' => 'video/3gp',
'mp4' => 'video/mp4',
'm4a' => 'audio/x-m4a',
'f4v' => 'video/mp4',
'webm' => 'video/webm',
'aac' => 'audio/x-acc',
'm4u' => 'application/vnd.mpegurl',
'm3u' => 'text/plain',
'xspf' => 'application/xspf+xml',
'vlc' => 'application/videolan',
'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
'au' => 'audio/x-au',
'ac3' => 'audio/ac3',
'flac' => 'audio/x-flac',
'ogg' => 'audio/ogg',
'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
'ics' => 'text/calendar',
'ical' => 'text/calendar',
'zsh' => 'text/x-scriptzsh',
'7zip' => array('application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
'vcf' => 'text/x-vcard'
);

View File

@ -0,0 +1,2 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

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

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'login';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

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

@ -0,0 +1,49 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$smileys = array(
':-)' => 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', 'exclaim'),
':question:' => array('question.gif', '19', '19', 'question')
);

View File

@ -0,0 +1,188 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$platforms = array(
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',
'windows nt 6.2' => 'Windows 8',
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.1' => 'Windows XP',
'windows nt 5.0' => 'Windows 2000',
'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 phone' => 'Windows Phone',
'windows' => 'Unknown Windows OS',
'android' => 'Android',
'blackberry' => 'BlackBerry',
'iphone' => 'iOS',
'ipad' => 'iOS',
'ipod' => 'iOS',
'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',
'symbian' => 'Symbian OS'
);
$browsers = array(
'OPR' => 'Opera',
'Flock' => 'Flock',
'Chrome' => 'Chrome',
'Opera.*?Version' => 'Opera',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Trident.* rv' => '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',
'Maxthon' => 'Maxthon',
'Ubuntu' => 'Ubuntu Web Browser'
);
$mobiles = array(
'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'
'motorola' => 'Motorola',
'nokia' => 'Nokia',
'palm' => 'Palm',
'iphone' => 'Apple iPhone',
'ipad' => 'iPad',
'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',
'playstation 3' => 'PlayStation 3',
'playstation vita' => 'PlayStation Vita',
'hiptop' => 'Danger Hiptop',
'nec-' => 'NEC',
'panasonic' => 'Panasonic',
'philips' => 'Philips',
'sagem' => 'Sagem',
'sanyo' => 'Sanyo',
'spv' => 'SPV',
'zte' => 'ZTE',
'sendo' => 'Sendo',
'nintendo dsi' => 'Nintendo DSi',
'nintendo ds' => 'Nintendo DS',
'nintendo 3ds' => 'Nintendo 3DS',
'wii' => 'Nintendo Wii',
'open web' => 'Open Web',
'openweb' => 'OpenWeb',
'android' => 'Android',
'symbian' => 'Symbian',
'SymbianOS' => 'SymbianOS',
'elaine' => 'Palm',
'series60' => 'Symbian S60',
'windows ce' => 'Windows CE',
'obigo' => 'Obigo',
'netfront' => 'Netfront Browser',
'openwave' => 'Openwave Browser',
'mobilexplorer' => 'Mobile Explorer',
'operamini' => 'Opera Mini',
'opera mini' => 'Opera Mini',
'opera mobi' => 'Opera Mobile',
'fennec' => 'Firefox Mobile',
'digital paths' => 'Digital Paths',
'avantgo' => 'AvantGo',
'xiino' => 'Xiino',
'novarra' => 'Novarra Transcoder',
'vodafone' => 'Vodafone',
'docomo' => 'NTT DoCoMo',
'o2' => 'O2',
'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'
);
$robots = array(
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'baiduspider' => 'Baiduspider',
'bingbot' => 'Bing',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'askjeeves' => 'AskJeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
'yandex' => 'YandexBot',
'mediapartners-google' => 'MediaPartners Google',
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
'adsbot-google' => 'AdsBot Google',
'feedfetcher-google' => 'Feedfetcher Google',
'curious george' => 'Curious George'
);

2964
application/controllers/Admin.php Executable file

File diff suppressed because it is too large Load Diff

162
application/controllers/Login.php Executable file
View File

@ -0,0 +1,162 @@
<?php if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Login extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('crud_model');
$this->load->database();
$this->load->library('session');
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 2010 05:00:00 GMT");
}
public function index()
{
if ($this->session->userdata('admin_login') == 1)
{
redirect(base_url() . 'admin/panel/', 'refresh');
}
if ($this->session->userdata('teacher_login') == 1)
{
redirect(base_url() . 'teacher/teacher_dashboard/', 'refresh');
}
if ($this->session->userdata('student_login') == 1)
{
redirect(base_url() . 'student/panel/', 'refresh');
}
if ($this->session->userdata('parent_login') == 1)
{
redirect(base_url() . 'parents/panel/', 'refresh');
}
$this->load->view('backend/login');
}
function lost_password($param1 = '', $param2 = '')
{
if($param1 == 'recovery')
{
$email = $_POST["field"];
$reset_account_type = '';
$new_password = substr( md5( rand(100000000,20000000000) ) , 0,7);
$new_hashed_password = sha1($new_password);
$query = $this->db->get_where('admin' , array('email' => $email));
if ($query->num_rows() > 0)
{
$this->db->where('email' , $email);
$this->db->update('admin' , array('password' => $new_hashed_password));
$this->crud_model->lost_password($email , $new_password);
}
$query = $this->db->get_where('teacher' , array('email' => $email));
if ($query->num_rows() > 0)
{
$this->db->where('email' , $email);
$this->db->update('teacher' , array('password' => $new_hashed_password));
$this->crud_model->lost_password($email , $new_password);
}
$query = $this->db->get_where('parent' , array('email' => $email));
if ($query->num_rows() > 0)
{
$this->db->where('email' , $email);
$this->db->update('parent' , array('password' => $new_hashed_password));
$this->crud_model->lost_password($email , $new_password);
}
$query = $this->db->get_where('student' , array('email' => $email));
if ($query->num_rows() > 0)
{
$this->db->where('email' , $email);
$this->db->update('student' , array('password' => $new_hashed_password));
$this->crud_model->lost_password($email , $new_password);
}
$this->session->set_flashdata('flash_message' , get_phrase('success'));
redirect(base_url(), 'refresh');
}
$this->load->view('backend/lost');
}
function ajax_login()
{
$response = array();
$email = $_POST["email"];
$password = sha1($_POST["password"]);
$response['submitted_data'] = $_POST;
$login_status = $this->validate_login($email, $password);
$response['login_status'] = $login_status;
if ($login_status == 'success')
{
$response['redirect_url'] = '';
}
echo json_encode($response);
}
function validate_login($email = '', $password = '')
{
$credential = array('username' => $email, 'password' => $password);
$query = $this->db->get_where('admin', $credential);
if ($query->num_rows() > 0)
{
$row = $query->row();
$this->session->set_userdata('admin_login', $row->status);
$this->session->set_userdata('admin_id', $row->admin_id);
$this->session->set_userdata('login_user_id', $row->admin_id);
$this->session->set_userdata('name', $row->name);
$this->session->set_userdata('login_type', 'admin');
return 'success';
}
$query = $this->db->get_where('teacher', $credential);
if ($query->num_rows() > 0)
{
$row = $query->row();
$this->session->set_userdata('teacher_login', '1');
$this->session->set_userdata('teacher_id', $row->teacher_id);
$this->session->set_userdata('login_user_id', $row->teacher_id);
$this->session->set_userdata('name', $row->name);
$this->session->set_userdata('login_type', 'teacher');
return 'success';
}
$query = $this->db->get_where('student', $credential);
if ($query->num_rows() > 0)
{
$row = $query->row();
$this->session->set_userdata('student_login', $row->student_session);
$this->session->set_userdata('student_id', $row->student_id);
$this->session->set_userdata('login_user_id', $row->student_id);
$this->session->set_userdata('name', $row->name);
$this->session->set_userdata('login_type', 'student');
return 'success';
}
$query = $this->db->get_where('parent', $credential);
if ($query->num_rows() > 0)
{
$row = $query->row();
$this->session->set_userdata('parent_login', '1');
$this->session->set_userdata('parent_id', $row->parent_id);
$this->session->set_userdata('login_user_id', $row->parent_id);
$this->session->set_userdata('name', $row->name);
$this->session->set_userdata('login_type', 'parent');
return 'success';
}
return 'invalid';
}
function four_zero_four()
{
$this->load->view('four_zero_four');
}
function logout()
{
$this->session->sess_destroy();
$this->session->set_flashdata('logout_notification', 'logged_out');
redirect(base_url(), 'refresh');
}
}

View File

@ -0,0 +1,579 @@
<?php if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Mobile extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->database();
if ($this->validate_auth_key() != 'success')
die;
}
function get_class() {
$response = array();
$classes = $this->db->get('class')->result_array();
foreach($classes as $row) {
$data['class_id'] = $row['class_id'];
$data['name'] = $row['name'];
$data['name_numeric'] = $row['name_numeric'];
$data['teacher_id'] = $row['teacher_id'];
$sections = $this->db->get_where('section' , array('class_id' => $row['class_id']))->result_array();
$data['sections'] = $sections;
array_push($response , $data);
}
echo json_encode($response);
}
function get_image_url($type = '', $id = '') {
$type = $this->input->post('user_type');
$id = $this->input->post('user_id');
$response = array();
if (file_exists('uploads/' . $type . '_image/' . $id . '.jpg'))
$response['image_url'] = base_url() . 'uploads/' . $type . '_image/' . $id . '.jpg';
else
$response['image_url'] = base_url() . 'uploads/user.jpg';
echo json_encode($response);
}
function get_system_info() {
$response['system_name'] = $this->db->get_where('settings' , array('type' => 'system_name'))->row()->description;
echo json_encode($response);
}
function get_students_of_class() {
$response = array();
$class_id = $this->input->post('class_id');
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$students = $this->db->get_where('enroll' , array('class_id' => $class_id , 'year' => $running_year))->result_array();
foreach ($students as $row) {
$data['student_id'] = $row['student_id'];
$data['roll'] = $row['roll'];
$data['name'] = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->name;
$data['birthday'] = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->birthday;
$data['gender'] = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->sex;
$data['address'] = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->address;
$data['phone'] = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->phone;
$data['email'] = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->email;
$data['class'] = $this->db->get_where('class' , array('class_id' => $row['class_id']))->row()->name;
$data['section'] = $this->db->get_where('section' , array('section_id' => $row['section_id']))->row()->name;
$parent_id = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->parent_id;
$data['parent_name']= $this->db->get_where('parent' , array('parent_id' => $parent_id))->row()->name;
$data['image_url'] = $this->crud_model->get_image_url( 'student' , $row['student_id'] );
array_push($response , $data);
}
echo json_encode($response);
}
function get_student_profile_information() {
$response = array();
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$student_id = $this->input->post('student_id');
$roll = $this->db->get_where('enroll' , array('student_id' => $student_id , 'year' => $running_year))->row()->roll;
$class_id = $this->db->get_where('enroll' , array('student_id' => $student_id , 'year' => $running_year))->row()->class_id;
$section_id = $this->db->get_where('enroll' , array('student_id' => $student_id , 'year' => $running_year))->row()->section_id;
$student_profile= $this->db->get_where('student' , array('student_id' => $student_id))->result_array();
foreach ($student_profile as $row) {
$data['student_id'] = $row['student_id'];
$data['name'] = $row['name'];
$data['birthday'] = $row['birthday'];
$data['gender'] = $row['sex'];
$data['address'] = $row['address'];
$data['phone'] = $row['phone'];
$data['email'] = $row['email'];
$data['roll'] = $roll;
$data['class'] = $class_id;
$data['section'] = $section_id;
$data['parent_name']= $this->db->get_where('parent' , array('parent_id' => $row['parent_id']))->row()->name;
$data['image_url'] = $this->crud_model->get_image_url( 'student' , $row['student_id'] );
array_push($response , $data);
}
echo json_encode($response);
}
function get_student_mark_information() {
$response = array();
$mark_array = array();
$exam_id = $this->input->post('exam_id');
$student_id = $this->input->post('student_id');
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$student_marks = $this->db->get_where('mark' , array('exam_id' => $exam_id ,
'student_id' => $student_id,
'year' => $running_year))->result_array();
$response['exam_id'] = $exam_id;
foreach ($student_marks as $row) {
$data['mark_obtained'] = $row['mark_obtained'];
$data['subject'] = $this->db->get_where('subject' ,
array('subject_id' => $row['subject_id'],
'year' => $running_year))->row()->name;
$grade = $this->crud_model->get_grade($row['mark_obtained']);
$data['grade'] = $grade['name'];
array_push($mark_array , $data);
}
$response['marks'] = $mark_array;
echo json_encode($response);
}
function get_teachers() {
$response = array();
$teachers = $this->db->get('teacher')->result_array();
foreach ($teachers as $row) {
$data['teacher_id'] = $row['teacher_id'];
$data['name'] = $row['name'];
$data['birthday'] = $row['birthday'];
$data['gender'] = $row['sex'];
$data['address'] = $row['address'];
$data['phone'] = $row['phone'];
$data['email'] = $row['email'];
$data['image_url'] = $this->crud_model->get_image_url( 'teacher' , $row['teacher_id'] );
array_push($response , $data);
}
echo json_encode($response);
}
function get_teacher_profile() {
$response = array();
$teacher_id = $this->input->post('teacher_id');
$response = $this->db->get_where('teacher' , array('teacher_id' => $teacher_id))->row();
echo json_encode($response);
}
function get_parents() {
$response = array();
$parents = $this->db->get('parent')->result_array();
foreach ($parents as $row) {
$data['parent_id'] = $row['parent_id'];
$data['name'] = $row['name'];
$data['profession'] = $row['profession'];
$data['address'] = $row['address'];
$data['phone'] = $row['phone'];
$data['email'] = $row['email'];
$data['image_url'] = $this->crud_model->get_image_url( 'parent' , $row['parent_id'] );
array_push($response , $data);
}
echo json_encode($response);
}
function get_parent_profile() {
$response = array();
$parent_id = $this->input->post('parent_id');
$response = $this->db->get_where('parent' , array('parent_id' => $parent_id))->row();
echo json_encode($response);
}
function get_accounting() {
$response = array();
$month = $this->input->post('month');
$year = $this->input->post('year');
$type = $this->input->post('type');
$start_timestamp= strtotime("1-".$month."-".$year);
$end_timestamp = strtotime("30-".$month."-".$year);
$this->db->where("timestamp >=" , $start_timestamp);
$this->db->where("timestamp <=" , $end_timestamp);
$this->db->where("payment_type" , $type);
$response = $this->db->get('payment')->result_array();
echo json_encode($response);
}
function get_attendance() {
$response = array();
$date = $this->input->post('date');
$month = $this->input->post('month');
$year = $this->input->post('year');
$class_id = $this->input->post('class_id');
$timestamp = strtotime($date.'-'.$month.'-'.$year);
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$students = $this->db->get_where('enroll' , array('class_id' => $class_id, 'year'=>$running_year))->result_array();
foreach ($students as $row) {
$data['student_id'] = $row['student_id'];
$data['roll'] = $row['roll'];
$data['name'] = $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->name;
$attendance_query = $this->db->get_where('attendance' , array('timestamp' => $timestamp ,
'student_id' => $row['student_id']));
if ( $attendance_query->num_rows() > 0) {
$attendance_result_row = $attendance_query->row();
$data['status'] = $attendance_result_row->status;
}
else {
$data['status'] = '0';
}
array_push($response , $data);
}
echo json_encode($response);
}
function get_class_routine() {
$response = array();
$class_id = $this->input->post('class_id');
$section_id = $this->input->post('section_id');
$day = $this->input->post('day');
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$class_routines = $this->db->get_where('class_routine' , array('class_id' => $class_id ,
'section_id' => $section_id ,
'day' => $day,
'year' => $running_year))->result_array();
foreach ($class_routines as $row) {
$data['class_id'] = $row['class_id'];
$data['subject'] = $this->db->get_where('subject',array('subject_id' => $row['subject_id'],
'year'=>$running_year))->row()->name;
$data['time_start'] = $row['time_start'];
$data['time_end'] = $row['time_end'];
$data['time_start_min'] = $row['time_start_min'];
$data['time_end_min'] = $row['time_end_min'];
$data['day'] = $row['day'];
array_push($response , $data);
}
echo json_encode($response);
}
function get_subject_name() {
$response = array();
$subject_id = $this->input->post('subject_id');
$response = $this->db->get_where('subject' , array('subject_id' => $subject_id))->row();
echo json_encode($response);
}
function get_event_calendar() {
$response = array();
$response = $this->db->get('noticeboard')->result_array();
echo json_encode($response);
}
function get_exam_list() {
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$response = array();
$response = $this->db->get_where('exam', array('year'=>$running_year))->result_array();
echo json_encode($response);
}
function get_subject_of_class() {
$response = array();
$class_id = $this->input->post('class_id');
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$subjects = $this->db->get_where('subject' , array('class_id' => $class_id , 'year' => $running_year))->result_array();
foreach ($subjects as $row) {
$data['subject_id'] = $row['subject_id'];
$data['name'] = $row['name'];
$teacher_query = $this->db->get_where('teacher' , array('teacher_id' => $row['teacher_id']));
if ( $teacher_query->num_rows() > 0) {
$teacher_query_row = $teacher_query->row();
$data['teacher_name'] = $teacher_query_row->name;
}
else {
$data['teacher_name'] = '';
}
array_push($response , $data);
}
echo json_encode($response);
}
function get_marks() {
$response = array();
$exam_id = $this->input->post('exam_id');
$class_id = $this->input->post('class_id');
$subject_id = $this->input->post('subject_id');
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$marks = $this->db->get_where('mark' , array('exam_id' => $exam_id ,
'class_id' => $class_id ,
'subject_id' => $subject_id,
'year' => $running_year))->result_array();
foreach ( $marks as $row ) {
$data['class_id'] = $row['class_id'];
$data['student_id'] = $row['student_id'];
$data['student_name'] = $this->db->get_where('student',array('student_id' => $row['student_id']))->row()->name;
$data['student_roll'] = $this->db->get_where('enroll',array('student_id' => $row['student_id'], 'year'=>$running_year))->row()->roll;
$data['exam_id'] = $row['exam_id'];
$data['mark_obtained'] = $row['mark_obtained'];
array_push($response , $data);
}
echo json_encode($response);
}
function get_loggedin_user_profile() {
$response = array();
$login_type = $this->input->post('login_type');
$login_user_id = $this->input->post('login_user_id');
$user_profile = $this->db->get_where( $login_type , array( $login_type.'_id' => $login_user_id ))->result_array();
foreach ($user_profile as $row) {
$data['name'] = $row['name'];
$data['email'] = $row['email'];
$data['image_url'] = $this->crud_model->get_image_url( $login_type , $login_user_id );
break;
}
array_push($response , $data);
echo json_encode($response);
}
function update_user_image() {
$response = array();
$user_type = $this->input->post('login_type');
$user_id = $this->input->post('login_user_id');
$directory = 'uploads/' . $user_type . '_image/' . $user_id . '.jpg';
move_uploaded_file($_FILES['user_image']['tmp_name'], $directory);
$response = array('update_status' => 'success');
echo json_encode($response);
}
function update_user_info() {
$response = array();
$user_type = $this->input->post('login_type');
$user_id = $this->input->post('login_user_id');
$data['name'] = $this->input->post('name');
$data['email'] = $this->input->post('email');
$this->db->where( $user_type . '_id' , $user_id);
$this->db->update( $user_type , $data);
$response = array('update_status' => 'success');
echo json_encode($response);
}
function update_user_password() {
$response = array();
$user_type = $this->input->post('login_type');
$user_id = $this->input->post('login_user_id');
$old_password = sha1( $this->input->post('old_password') );
$data['password'] = sha1( $this->input->post('new_password') );
$this->db->where( $user_type . '_id' , $user_id);
$this->db->where( 'password' , $old_password);
$verify_query = $this->db->get( $user_type );
if ( $verify_query->num_rows() > 0 ) {
$this->db->where( $user_type . '_id' , $user_id);
$this->db->update( $user_type , $data);
$response = array('update_status' => 'success');
}
else {
$response = array('update_status' => 'failed');
}
echo json_encode($response);
}
function get_total_summary() {
$response = array();
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$this->db->where('year' , $running_year);
$this->db->from('enroll');
$response['total_student'] = $this->db->count_all_results();
$response['total_teacher'] = $this->db->count_all('teacher');
$response['total_parent'] = $this->db->count_all('parent');
$check = array('timestamp' => strtotime(date('d-m-Y')) , 'status' => '1');
$query = $this->db->get_where('attendance' , $check);
$present_today = $query->num_rows();
$response['total_present_today'] = $present_today;
echo json_encode($response);
}
function getdata() {
$response = array();
$postvar = $this->input->post('postvar');
$response = $this->db->get_where('table' , array('postvar' => $postvar))->result_array();
echo json_encode($response);
}
function get_children_of_parent() {
$response = array();
$parent_id = $this->input->post('parent_id');
$response['children'] = $this->db->get_where('student' , array('parent_id' => $parent_id))->result_array();
echo json_encode($response);
}
function get_child_class_routine() {
}
function get_child_exam_marks() {
}
function get_child_accounting() {
}
function get_own_subjects() {
}
function get_own_class_routine() {
}
function get_own_marks() {
}
function get_single_student_accounting() {
$response = array();
$student_id = $this->input->post("student_id");
$this->db->where("student_id" , $student_id);
$response = $this->db->get('invoice')->result_array();
echo json_encode($response);
}
function login() {
$response = array();
$email = $this->input->post("email");
$password = sha1($this->input->post("password"));
$query = $this->db->get_where('admin', array('email' => $email , 'password' => $password));
if ($query->num_rows() > 0) {
$row = $query->row();
$authentication_key = md5( rand(10000, 1000000));
$response['status'] = 'success';
$response['login_type'] = 'admin';
$response['login_user_id'] = $row->admin_id;
$response['name'] = $row->name;
$response['authentication_key']=$authentication_key;
$this->db->where('admin_id' , $row->admin_id);
$this->db->update('admin' , array('authentication_key' => $authentication_key));
echo json_encode($response);
return;
}
$query = $this->db->get_where('teacher', array('email' => $email , 'password' => $password));
if ($query->num_rows() > 0) {
$row = $query->row();
$authentication_key = md5( rand(10000, 1000000));
$response['status'] = 'success';
$response['login_type'] = 'teacher';
$response['login_user_id'] = $row->teacher_id;
$response['name'] = $row->name;
$response['authentication_key']=$authentication_key;
$this->db->where('teacher_id' , $row->teacher_id);
$this->db->update('teacher' , array('authentication_key' => $authentication_key));
echo json_encode($response);
return;
}
$query = $this->db->get_where('student', array('email' => $email , 'password' => $password));
if ($query->num_rows() > 0) {
$running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
$row = $query->row();
$authentication_key = md5( rand(10000, 1000000));
$response['status'] = 'success';
$response['login_type'] = 'student';
$response['login_user_id'] = $row->student_id;
$response['name'] = $row->name;
$response['authentication_key']=$authentication_key;
$response['class_id'] = $this->db->get_where('enroll' , array(
'student_id' => $row->student_id , 'year' => $running_year
))->row()->class_id;
$response['section_id'] = $this->db->get_where('enroll' , array(
'student_id' => $row->student_id , 'year' => $running_year
))->row()->section_id;
$this->db->where('student_id' , $row->student_id);
$this->db->update('student' , array('authentication_key' => $authentication_key));
echo json_encode($response);
return;
}
$query = $this->db->get_where('parent', array('email' => $email , 'password' => $password));
if ($query->num_rows() > 0) {
$row = $query->row();
$authentication_key = md5( rand(10000, 1000000));
$response['status'] = 'success';
$response['login_type'] = 'parent';
$response['login_user_id'] = $row->parent_id;
$response['name'] = $row->name;
$response['authentication_key']=$authentication_key;
$response['children'] = $this->db->get_where('student' , array('parent_id' => $row->parent_id))->result_array();
$this->db->where('parent_id' , $row->parent_id);
$this->db->update('parent' , array('authentication_key' => $authentication_key));
echo json_encode($response);
return;
}
else {
$response['status'] = 'failed';
}
echo json_encode($response);
}
function validate_auth_key() {
if ($this->input->post('authenticate') == 'false')
return 'success';
$response = array();
$authentication_key = $this->input->post("authentication_key");
$user_type = $this->input->post("user_type");
$query = $this->db->get_where($user_type, array('authentication_key' => $authentication_key));
if ($query->num_rows() > 0) {
$row = $query->row();
$response['status'] = 'success';
$response['login_type'] = 'admin';
if ( $user_type == 'admin' )
$response['login_user_id'] = $row->admin_id;
if ( $user_type == 'teacher' )
$response['login_user_id'] = $row->teacher_id;
if ( $user_type == 'student' )
$response['login_user_id'] = $row->student_id;
if ( $user_type == 'parent' )
$response['login_user_id'] = $row->parent_id;
$response['authentication_key']=$authentication_key;
}
else {
$response['status'] = 'failed';
}
return $response['status'];
}
}

View File

@ -0,0 +1,28 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Modal extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('session');
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}
public function index()
{
}
function popup($page_name = '' , $param2 = '' , $param3 = '', $param4 = '')
{
$account_type = $this->session->userdata('login_type');
$page_data['param2'] = $param2;
$page_data['param3'] = $param3;
$page_data['param4'] = $param4;
$this->load->view( 'backend/'.$account_type.'/'.$page_name.'.php' ,$page_data);
echo '<script src="'.base_url().'assets/js/neon-custom-ajax.js"></script>';
}
}

View File

@ -0,0 +1,28 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Multilanguage extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('session');
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}
function index()
{
}
function select_language($language = 'english')
{
$this->session->set_userdata('current_language', $language);
redirect(base_url(), 'refresh');
}
}

View File

@ -0,0 +1,498 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Parents extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('session');
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}
public function index()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($this->session->userdata('parent_login') == 1)
{
redirect(base_url() . 'parents/panel/', 'refresh');
}
}
function view_report($report_code = '')
{
if ($this->session->userdata('parent_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$page_data['code'] = $report_code;
$page_data['page_name'] = 'view_report';
$page_data['page_title'] = get_phrase('report_details');
$this->load->view('backend/index', $page_data);
}
function student_report($param1 = '', $param2 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
if($param1 == 'response')
{
$data['report_code'] = $this->input->post('report_code');
$data['message'] = $this->input->post('message');
$data['date'] = date('d M, Y');
$data['sender_type'] = $this->session->userdata('login_type');
$data['sender_id'] = $this->session->userdata('login_user_id');
$this->db->insert('report_response', $data);
}
$page_data['page_name'] = 'student_report';
$page_data['page_title'] = get_phrase('reports');
$this->load->view('backend/index', $page_data);
}
function my_profile($param1 = "", $page_id = "")
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
if($param1 == 'update')
{
$data['name'] = $this->input->post('name');
$data['email'] = $this->input->post('email');
$data['phone'] = $this->input->post('phone');
$data['address'] = $this->input->post('address');
$data['profession'] = $this->input->post('profession');
if($this->input->post('password') != "")
{
$data['password'] = sha1($this->input->post('password'));
}
$this->db->where('parent_id', $this->session->userdata('login_user_id'));
$this->db->update('parent', $data);
move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/parent_image/' . $this->session->userdata('login_user_id') . '.jpg');
$this->session->set_flashdata('flash_message' , get_phrase('successfully_updated'));
redirect(base_url() . 'parents/my_profile/', 'refresh');
}
$data['page_name'] = 'my_profile';
$data['page_title'] = get_phrase('profile');
$this->load->view('backend/index', $data);
}
function subject_marks($data)
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['data'] = $data;
$page_data['page_name'] = 'subject_marks';
$page_data['page_title'] = get_phrase('marks');
$this->load->view('backend/index',$page_data);
}
function online_exams()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'online_exams';
$page_data['page_title'] = get_phrase('online_exams');
$this->load->view('backend/index', $page_data);
}
function polls($param1 = '', $param2 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
if($param1 == 'response')
{
$data['poll_code'] = $this->input->post('poll_code');
$data['answer'] = $this->input->post('answer');
$user = $this->session->userdata('login_user_id');
$user_type = $this->session->userdata('login_type');
$data['user'] = $user_type ."-".$user;
$data['date'] = date('d M, Y');
return $this->db->insert('poll_response', $data);
}
}
function homework()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'homework';
$page_data['page_title'] = get_phrase('homework');
$this->load->view('backend/index', $page_data);
}
function study_material()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'study_material';
$page_data['page_title'] = get_phrase('study_material');
$this->load->view('backend/index', $page_data);
}
function homeworkroom($param1 = '' , $param2 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['homework_code'] = $param1;
$page_data['page_name'] = 'homework_room';
$page_data['page_title'] = get_phrase('homework');
$this->load->view('backend/index', $page_data);
}
function syllabus()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'syllabus';
$page_data['page_title'] = get_phrase('syllabus');
$this->load->view('backend/index', $page_data);
}
function view_invoice($id)
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['invoice_id'] = $id;
$page_data['page_name'] = 'view_invoice';
$page_data['page_title'] = get_phrase('view_invoice');
$this->load->view('backend/index', $page_data);
}
function examroom()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'examroom';
$page_data['page_title'] = "Examen";
$this->load->view('backend/index', $page_data);
}
function panel()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'panel';
$page_data['page_title'] = get_phrase('dashboard');
$this->load->view('backend/index', $page_data);
}
function teachers()
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'teachers';
$page_data['page_title'] = get_phrase('teachers');
$this->load->view('backend/index', $page_data);
}
function download_unit_content($academic_syllabus_code)
{
if($this->session->userdata('parent_login')!=1)
{
redirect(base_url() , 'refresh');
}
$file_name = $this->db->get_where('academic_syllabus', array('academic_syllabus_code' => $academic_syllabus_code))->row()->file_name;
$this->load->helper('download');
$data = file_get_contents("uploads/syllabus/" . $file_name);
$name = $file_name;
force_download($name, $data);
}
function marks_print_view($student_id , $exam_id)
{
if ($this->session->userdata('parent_login') != 1)
{
redirect('login', 'refresh');
}
$class_id = $this->db->get_where('enroll' , array('student_id' => $student_id , 'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description))->row()->class_id;
$class_name = $this->db->get_where('class' , array('class_id' => $class_id))->row()->name;
$page_data['student_id'] = $student_id;
$page_data['class_id'] = $class_id;
$page_data['exam_id'] = $exam_id;
$this->load->view('backend/parent/marks_print_view', $page_data);
}
function noticeboard($param1 = '', $param2 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect('login', 'refresh');
}
$page_data['page_name'] = 'noticeboard';
$page_data['page_title'] = get_phrase('noticeboard');
$this->load->view('backend/index', $page_data);
}
function marks($param1 = '', $param2 ='')
{
if ($this->session->userdata('parent_login') != 1)
redirect(base_url(), 'refresh');
$parents = $this->db->get_where('student' , array('student_id' => $param1))->result_array();
foreach ($parents as $row)
{
if($row['parent_id'] == $this->session->userdata('login_user_id'))
{
$page_data['student_id'] = $param1;
} else if($row['parent_id'] != $this->session->userdata('login_user_id'))
{
redirect(base_url(), 'refresh');
}
}
$page_data['page_name'] = 'marks';
$page_data['page_title'] = get_phrase('marks');
$this->load->view('backend/index', $page_data);
}
function library($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect('login', 'refresh');
}
$page_data['page_name'] = 'library';
$page_data['page_title'] = get_phrase('library');
$this->load->view('backend/index', $page_data);
}
function class_routine($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['student_id'] = $param1;
$page_data['page_name'] = 'class_routine';
$page_data['page_title'] = get_phrase('class_routine');
$this->load->view('backend/index', $page_data);
}
function attendance_report()
{
if($this->session->userdata('parent_login')!=1)
{
redirect(base_url() , 'refresh');
}
$page_data['month'] = date('m');
$page_data['page_name'] = 'attendance_report';
$page_data['page_title'] = get_phrase('attendance_report');
$this->load->view('backend/index',$page_data);
}
function report_attendance_view($class_id = '' , $section_id = '', $student_id = '', $month = '', $param1 = '')
{
if($this->session->userdata('parent_login')!=1)
{
redirect(base_url() , 'refresh');
}
$class_name = $this->db->get_where('class' , array('class_id' => $class_id))->row()->name;
$page_data['class_id'] = $class_id;
$page_data['month'] = $month;
$page_data['student_id'] = $student_id;
$page_data['page_name'] = 'report_attendance_view';
$section_name = $this->db->get_where('section' , array('section_id' => $section_id))->row()->name;
$page_data['section_id'] = $section_id;
$page_data['page_title'] = get_phrase('attendance_report');
$this->load->view('backend/index', $page_data);
}
function attendance_report_selector()
{
if($this->session->userdata('parent_login')!=1)
{
redirect(base_url() , 'refresh');
}
$data['class_id'] = $this->db->get_where('enroll', array('student_id' => $this->input->post('student_id')))->row()->class_id;
$data['section_id'] = $this->db->get_where('enroll', array('student_id' => $this->input->post('student_id')))->row()->section_id;
$data['year'] = $this->input->post('year');
$data['student_id'] = $this->input->post('student_id');
$data['month'] = $this->input->post('month');
redirect(base_url().'parents/report_attendance_view/'.$data['class_id'].'/'.$data['section_id'].'/'.$data['student_id'].'/'.$data['month'],'refresh');
}
function exam_routine($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'exam_routine';
$page_data['page_title'] = get_phrase('exam_routine');
$this->load->view('backend/index', $page_data);
}
function invoice($student_id = '' , $param1 = '', $param2 = '', $param3 = '')
{
if ($param1 == 'make_payment')
{
$invoice_id = $this->input->post('invoice_id');
$system_settings = $this->db->get_where('settings', array('type' => 'paypal_email'))->row();
$invoice_details = $this->db->get_where('invoice', array('invoice_id' => $invoice_id))->row();
$this->paypal->add_field('rm', 2);
$this->paypal->add_field('no_note', 0);
$this->paypal->add_field('item_name', $invoice_details->title);
$this->paypal->add_field('amount', $invoice_details->due);
$this->paypal->add_field('custom', $invoice_details->invoice_id);
$this->paypal->add_field('business', $system_settings->description);
$this->paypal->add_field('notify_url', base_url() . 'student/invoice/');
$this->paypal->add_field('cancel_return', base_url() . 'student/invoice/paypal_cancel');
$this->paypal->add_field('return', base_url() . 'student/invoice/paypal_success');
$this->paypal->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$this->paypal->submit_paypal_post();
}
if ($param1 == 'paypal_cancel')
{
redirect(base_url() . 'parents/invoice/' . $student_id, 'refresh');
}
if ($param1 == 'paypal_success')
{
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$ipn_response .= "\n$key=$value";
}
$data['payment_details'] = $ipn_response;
$data['payment_timestamp'] = strtotime(date("m/d/Y"));
$data['payment_method'] = 'paypal';
$data['status'] = 'completed';
$invoice_id = $_POST['custom'];
$this->db->where('invoice_id', $invoice_id);
$this->db->update('invoice', $data);
$data2['method'] = 'paypal';
$data2['invoice_id'] = $_POST['custom'];
$data2['timestamp'] = strtotime(date("m/d/Y"));
$data2['payment_type'] = 'income';
$data2['title'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->title;
$data2['description'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->description;
$data2['student_id'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->student_id;
$data2['amount'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->amount;
$this->db->insert('payment' , $data2);
redirect(base_url() . 'parents/invoice/'.$student_id, 'refresh');
}
if ($student_id == 'student')
{
redirect(base_url() . 'parents/invoice/' . $this->input->post('student_id'), 'refresh');
}
$parent_profile = $this->db->get_where('parent', array('parent_id' => $this->session->userdata('parent_id')))->row();
$page_data['student_id'] = $student_id;
$page_data['page_name'] = 'invoice';
$page_data['page_title'] = get_phrase('payments');
$this->load->view('backend/index', $page_data);
}
function news_message($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == 'add')
{
$this->crud_model->create_news_message($this->input->post('news_code'));
}
}
function exam_results($code = '')
{
if ($this->session->userdata('parent_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$page_data['exam_code'] = $code;
$page_data['page_name'] = 'exam_results';
$page_data['page_title'] = get_phrase('exam_results');
$this->load->view('backend/index', $page_data);
}
function read($code = "")
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'read';
$page_data['page_title'] = get_phrase('noticeboard');
$page_data['code'] = $code;
$this->load->view('backend/index', $page_data);
}
function message($param1 = 'message_home', $param2 = '', $param3 = '')
{
if ($this->session->userdata('parent_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == 'send_new')
{
$this->session->set_flashdata('flash_message' , "Mensaje enviado con éxito");
$message_thread_code = $this->crud_model->send_new_private_message();
move_uploaded_file($_FILES["file_name"]["tmp_name"], "uploads/messages/" . $_FILES["file_name"]["name"]);
$this->session->set_flashdata('flash_message' , get_phrase('message_sent'));
redirect(base_url() . 'parents/message/message_read/' . $message_thread_code, 'refresh');
}
if ($param1 == 'send_reply')
{
$this->crud_model->send_reply_message($param2);
move_uploaded_file($_FILES["file_name"]["tmp_name"], "uploads/messages/" . $_FILES["file_name"]["name"]);
$this->session->set_flashdata('flash_message' , get_phrase('reply_sent'));
redirect(base_url() . 'parents/message/message_read/' . $param2, 'refresh');
}
if ($param1 == 'message_read')
{
$page_data['current_message_thread_code'] = $param2;
$this->crud_model->mark_thread_messages_read($param2);
}
$page_data['infouser'] = $param2;
$page_data['message_inner_page_name'] = $param1;
$page_data['page_name'] = 'message';
$page_data['page_title'] = get_phrase('private_messages');
$this->load->view('backend/index', $page_data);
}
}

View File

@ -0,0 +1,80 @@
<?php if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Register extends CI_Controller
{
function __construct() {
parent::__construct();
$this->load->model('crud_model');
$this->load->database();
$this->load->library('session');
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 2010 05:00:00 GMT");
}
public function index()
{
$this->load->view('backend/register');
}
function create_account($param1 = '')
{
if($param1 == 'teacher')
{
$data['name'] = $this->input->post('name');
$data['username'] = $this->input->post('username');
$data['address'] = $this->input->post('address');
$data['phone'] = $this->input->post('phone');
$data['email'] = $this->input->post('email');
$data['sex'] = $this->input->post('sex');
$data['birthday'] = $this->input->post('birthday');
$data['type'] = "teacher";
$data['password'] = sha1($this->input->post('password'));
$this->db->insert('pending_users', $data);
$user_id = $this->db->insert_id();
$this->crud_model->welcome_user($user_id);
$this->session->set_flashdata('flash_message' , "Your account has been created, however an administrator must approve your account in order to log in, an email will be sent to your email when your account is approved.");
redirect(base_url() . 'register', 'refresh');
}
if($param1 == 'student')
{
$data['class_id'] = $this->input->post('class_id');
$data['section_id'] = $this->input->post('section_id');
$data['parent_id'] = $this->input->post('parent_id');
$data['name'] = $this->input->post('name');
$data['username'] = $this->input->post('username');
$data['address'] = $this->input->post('address');
$data['phone'] = $this->input->post('phone');
$data['email'] = $this->input->post('email');
$data['sex'] = $this->input->post('sex');
$data['birthday'] = $this->input->post('birthday');
$data['roll'] = $this->input->post('roll');
$data['type'] = "student";
$data['password'] = sha1($this->input->post('password'));
$this->db->insert('pending_users', $data);
$user_id = $this->db->insert_id();
$this->crud_model->welcome_user($user_id);
$this->session->set_flashdata('flash_message' , "Your account has been created, however an administrator must approve your account in order to log in, an email will be sent to your email when your account is approved.");
redirect(base_url() . 'register', 'refresh');
}
if($param1 == 'parent')
{
$data['name'] = $this->input->post('name');
$data['username'] = $this->input->post('username');
$data['address'] = $this->input->post('address');
$data['phone'] = $this->input->post('phone');
$data['email'] = $this->input->post('email');
$data['profession'] = $this->input->post('profession');
$data['type'] = "parent";
$data['password'] = sha1($this->input->post('password'));
$this->db->insert('pending_users', $data);
$user_id = $this->db->insert_id();
$this->crud_model->welcome_user($user_id);
$this->session->set_flashdata('flash_message' , "Your account has been created, however an administrator must approve your account in order to log in, an email will be sent to your email when your account is approved.");
redirect(base_url() . 'register', 'refresh');
}
}
}

View File

@ -0,0 +1,894 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Student extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('session');
$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}
public function index()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($this->session->userdata('student_login') == 1)
{
redirect(base_url() . 'student/panel/', 'refresh');
}
}
function polls($param1 = '', $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if($param1 == 'response')
{
$data['poll_code'] = $this->input->post('poll_code');
$data['answer'] = $this->input->post('answer');
$user = $this->session->userdata('login_user_id');
$user_type = $this->session->userdata('login_type');
$data['user'] = $user_type ."-".$user;
$data['date'] = date('d M, Y');
return $this->db->insert('poll_response', $data);
}
}
function entrys($e)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$how_hear = count($_POST['answer']) ? $_POST['answer'] : array();
$how = count($_POST['ques_id']) ? $_POST['ques_id'] : array();
$exam_code = $_POST['exam_code'];
$data['student_answer'] = implode(',',$how_hear);
$data['student_id'] = $this->session->userdata('login_user_id');
$data['question_id'] = implode(',',$how);
$data['answered'] = "answered";
$data['time'] = $_POST['time_left'];
$data['total_time'] = $_POST['time'];
$data['exam_code'] = $exam_code;
$this->db->insert('student_question', $data);
redirect(base_url() . 'student/online_exams/', 'refresh');
}
function exam_view($param1 = '' , $param2 = '', $question_id)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == 'take_exam')
{
$page_data['room_page'] = 'take_exam';
$page_data['exam_code'] = $param2;
if($this->db->get_where('student_question',array('exam_code'=>$param2,'student_id' => $this->session->userdata('login_user_id')))->row()->answered == 'answered')
{
redirect(base_url() . 'student/online_exams/', 'refresh');
}
}
if ($param1 == 'results')
{
$page_data['room_page'] = 'results';
$page_data['exam_code'] = $param2;
}
$page_data['page_name'] = 'exam_room';
$page_data['page_title'] = "";
$this->load->view('backend/index', $page_data);
}
function take($exam_code)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['questions'] = $this->db->get_where('questions' , array('exam_code' => $exam_code))->result_array();
if($this->db->get_where('student_question',array('exam_code'=>$exam_code,'student_id'=>$this->session->userdata('login_user_id')))->row()->answered == 'answered')
{
redirect(base_url() . 'index.php?student/online_exams/', 'refresh');
}
$page_data['exam_code'] = $exam_code;
$page_data['page_name'] = 'take';
$page_data['page_title'] = "";
$this->load->view('backend/index', $page_data);
}
function request($param1 = "", $param2 = "")
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == "create")
{
$data['student_id'] = $this->session->userdata('login_user_id');
$data['description'] = $this->input->post('description');
$data['title'] = $this->input->post('title');
$data['start_date'] = $this->input->post('start_date');
$data['end_date'] = $this->input->post('end_date');
$data['status'] = 0;
$this->db->insert('students_request', $data);
redirect(base_url() . 'student/request', 'refresh');
}
$data['page_name'] = 'request';
$data['page_title'] = get_phrase('permissions');
$this->load->view('backend/index', $data);
}
function attendance_report()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['month'] = date('m');
$page_data['page_name'] = 'attendance_report';
$page_data['page_title'] = get_phrase('attendance_report');
$this->load->view('backend/index',$page_data);
}
function examroom($code = "")
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['code'] = $code;
$page_data['page_name'] = 'examroom';
$page_data['page_title'] = get_phrase('take_exam');
$this->load->view('backend/index',$page_data);
}
function exam($code = "")
{
$page_data['questions'] = $this->db->get_where('questions' , array('exam_code' => $code))->result_array();
if($this->db->get_where('student_question',array('exam_code'=>$code,'student_id'=>$this->session->userdata('login_user_id')))->row()->answered == 'answered')
{
redirect(base_url() . 'student/online_exams/', 'refresh');
}
$page_data['exam_code'] = $code;
$page_data['page_name'] = 'exam';
$page_data['page_title'] = get_phrase('online_exam');
$this->load->view('backend/index',$page_data);
}
function exam_results($code = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['exam_code'] = $code;
$page_data['page_name'] = 'exam_results';
$page_data['page_title'] = get_phrase('exam_results');
$this->load->view('backend/index', $page_data);
}
function view_results()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'view_results';
$page_data['page_title'] = "";
$this->load->view('backend/index',$page_data);
}
function print_marks()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['month'] = date('m');
$page_data['page_name'] = 'print_marks';
$page_data['page_title'] = "";
$this->load->view('backend/index',$page_data);
}
function subject_marks($data)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['data'] = $data;
$page_data['page_name'] = 'subject_marks';
$page_data['page_title'] = get_phrase('subject_marks');
$this->load->view('backend/index',$page_data);
}
function view_invoice($id)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['invoice_id'] = $id;
$page_data['page_name'] = 'view_invoice';
$page_data['page_title'] = get_phrase('invoice');
$this->load->view('backend/index',$page_data);
}
function view_report($code)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['code'] = $code;
$page_data['page_name'] = 'view_report';
$page_data['page_title'] = get_phrase('view_report');
$this->load->view('backend/index',$page_data);
}
function view_new()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'view_new';
$page_data['page_title'] = "";
$this->load->view('backend/index',$page_data);
}
function view_event()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'view_event';
$page_data['page_title'] = "";
$this->load->view('backend/index',$page_data);
}
function my_profile($param1 = '', $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if($param1 == 'update')
{
$data['name'] = $this->input->post('name');
$data['email'] = $this->input->post('email');
$data['phone'] = $this->input->post('phone');
$data['address'] = $this->input->post('address');
$data['birthday'] = $this->input->post('birthday');
$data['name'] = $this->input->post('name');
if($this->input->post('password') != "")
{
$data['password'] = sha1($this->input->post('password'));
}
$this->db->where('student_id', $this->session->userdata('login_user_id'));
$this->db->update('student', $data);
move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/student_image/' . $this->session->userdata('login_user_id') . '.jpg');
redirect(base_url().'student/my_profile/','refresh');
}
$page_data['page_name'] = 'my_profile';
$page_data['page_title'] = get_phrase('profile');
$this->load->view('backend/index',$page_data);
}
function report_attendance_view($class_id = '' , $section_id = '', $month = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$class_name = $this->db->get_where('class' , array('class_id' => $class_id))->row()->name;
$page_data['class_id'] = $class_id;
$page_data['month'] = $month;
$page_data['page_name'] = 'report_attendance_view';
$section_name = $this->db->get_where('section' , array('section_id' => $section_id))->row()->name;
$page_data['section_id'] = $section_id;
$page_data['page_title'] = get_phrase('attendance_report');
$this->load->view('backend/index', $page_data);
}
function attendance_report_selector()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$data['class_id'] = $this->input->post('class_id');
$data['year'] = $this->input->post('year');
$data['month'] = $this->input->post('month');
$data['section_id'] = $this->input->post('section_id');
redirect(base_url().'student/report_attendance_view/'.$data['class_id'].'/'.$data['section_id'].'/'.$data['month'],'refresh');
}
function events($param1 = '', $param2 = '' , $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == 'edit')
{
$this->crud_model->calendar_event_edit($param2);
}
$page_data['page_name'] = 'events';
$page_data['page_title'] = "";
$this->load->view('backend/index', $page_data);
}
function panel()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'panel';
$page_data['page_title'] = get_phrase('dashboard');
$this->load->view('backend/index', $page_data);
}
function marks_print_view($student_id , $exam_id)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$class_id = $this->db->get_where('enroll' , array('student_id' => $student_id , 'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description))->row()->class_id;
$class_name = $this->db->get_where('class' , array('class_id' => $class_id))->row()->name;
$page_data['student_id'] = $student_id;
$page_data['class_id'] = $class_id;
$page_data['exam_id'] = $exam_id;
$this->load->view('backend/student/marks_print_view', $page_data);
}
function teacher_list($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == 'personal_profile')
{
$page_data['personal_profile'] = true;
$page_data['current_teacher_id'] = $param2;
}
$page_data['teachers'] = $this->db->get('teacher')->result_array();
$page_data['page_name'] = 'teacher';
$page_data['page_title'] = "";
$this->load->view('backend/index', $page_data);
}
function subject($param1 = '', $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$student_profile = $this->db->get_where('student', array('student_id' => $this->session->userdata('student_id')))->row();
$student_class_id = $this->db->get_where('enroll' , array('student_id' => $student_profile->student_id,'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description
))->row()->class_id;
$page_data['subjects'] = $this->db->get_where('subject', array('class_id' => $student_class_id,'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description))->result_array();
$page_data['page_name'] = 'subject';
$page_data['page_title'] = get_phrase('subjects');
$this->load->view('backend/index', $page_data);
}
function my_marks($student_id = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$student = $this->db->get_where('student' , array('student_id' => $student_id))->result_array();
foreach ($student as $row)
{
if($row['student_id'] == $this->session->userdata('login_user_id'))
{
$page_data['student_id'] = $student_id;
} else if($row['parent_id'] != $this->session->userdata('login_user_id'))
{
redirect(base_url(), 'refresh');
}
}
$class_id = $this->db->get_where('enroll' , array('student_id' => $student_id , 'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description))->row()->class_id;
$student_name = $this->db->get_where('student' , array('student_id' => $student_id))->row()->name;
$class_name = $this->db->get_where('class' , array('class_id' => $class_id))->row()->name;
$page_data['page_name'] = 'my_marks';
$page_data['page_title'] = get_phrase('marks');
$page_data['class_id'] = $class_id;
$this->load->view('backend/index', $page_data);
}
function class_routine($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$student_profile = $this->db->get_where('student', array('student_id' => $this->session->userdata('student_id')))->row();
$page_data['class_id'] = $this->db->get_where('enroll' , array('student_id' => $student_profile->student_id,'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description))->row()->class_id;
$page_data['student_id'] = $student_profile->student_id;
$page_data['page_name'] = 'class_routine';
$page_data['page_title'] = get_phrase('class_routine');
$this->load->view('backend/index', $page_data);
}
function exam_routine($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$student_profile = $this->db->get_where('student', array('student_id' => $this->session->userdata('student_id')))->row();
$page_data['class_id'] = $this->db->get_where('enroll' , array('student_id' => $student_profile->student_id,'year' => $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description))->row()->class_id;
$page_data['student_id'] = $student_profile->student_id;
$page_data['page_name'] = 'exam_routine';
$page_data['page_title'] = get_phrase('exam_routine');
$this->load->view('backend/index', $page_data);
}
function syllabus($student_id = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'syllabus';
$page_data['page_title'] = get_phrase('syllabus');
$page_data['student_id'] = $student_id;
$this->load->view('backend/index', $page_data);
}
function homework($student_id = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'homework';
$page_data['page_title'] = get_phrase('homework');
$page_data['student_id'] = $student_id;
$this->load->view('backend/index', $page_data);
}
function libreria_virtual($student_id = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'libreria_virtual';
$page_data['page_title'] = "";
$page_data['student_id'] = $student_id;
$this->load->view('backend/index', $page_data);
}
function online_exams($student_id = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'online_exams';
$page_data['page_title'] = get_phrase('online_exams');
$page_data['student_id'] = $student_id;
$this->load->view('backend/index', $page_data);
}
function download_unit_content($academic_syllabus_code)
{
$file_name = $this->db->get_where('academic_syllabus', array('academic_syllabus_code' => $academic_syllabus_code))->row()->file_name;
$this->load->helper('download');
$data = file_get_contents("uploads/syllabus/" . $file_name);
$name = $file_name;
force_download($name, $data);
}
function descargar_libro($libro_code)
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$file_name = $this->db->get_where('libreria', array('libro_code' => $libro_code))->row()->file_name;
$this->load->helper('download');
$data = file_get_contents("uploads/libreria/" . $file_name);
$name = $file_name;
force_download($name, $data);
}
function invoice($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == 'make_payment')
{
$invoice_id = $this->input->post('invoice_id');
$system_settings = $this->db->get_where('settings', array('type' => 'paypal_email'))->row();
$invoice_details = $this->db->get_where('invoice', array('invoice_id' => $invoice_id))->row();
$this->paypal->add_field('rm', 2);
$this->paypal->add_field('no_note', 0);
$this->paypal->add_field('item_name', $invoice_details->title);
$this->paypal->add_field('amount', $invoice_details->due);
$this->paypal->add_field('custom', $invoice_details->invoice_id);
$this->paypal->add_field('business', $system_settings->description);
$this->paypal->add_field('notify_url', base_url() . 'student/invoice/');
$this->paypal->add_field('cancel_return', base_url() . 'student/invoice/paypal_cancel');
$this->paypal->add_field('return', base_url() . 'student/invoice/paypal_success');
$this->paypal->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$this->paypal->submit_paypal_post();
}
if ($param1 == 'paypal_cancel')
{
redirect(base_url() . 'student/invoice/', 'refresh');
}
if ($param1 == 'paypal_success')
{
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$ipn_response .= "\n$key=$value";
}
$data['payment_details'] = $ipn_response;
$data['payment_timestamp'] = strtotime(date("m/d/Y"));
$data['payment_method'] = 'paypal';
$data['status'] = 'completed';
$invoice_id = $_POST['custom'];
$this->db->where('invoice_id', $invoice_id);
$this->db->update('invoice', $data);
$data2['method'] = 'paypal';
$data2['invoice_id'] = $_POST['custom'];
$data2['timestamp'] = strtotime(date("m/d/Y"));
$data2['payment_type'] = 'income';
$data2['title'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->title;
$data2['description'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->description;
$data2['student_id'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->student_id;
$data2['amount'] = $this->db->get_where('invoice' , array('invoice_id' => $data2['invoice_id']))->row()->amount;
$this->db->insert('payment' , $data2);
redirect(base_url() . 'student/invoice/', 'refresh');
}
$student_profile = $this->db->get_where('student', array('student_id' => $this->session->userdata('student_id')))->row();
$student_id = $student_profile->student_id;
$page_data['invoices'] = $this->db->get_where('invoice', array('student_id' => $student_id))->result_array();
$page_data['page_name'] = 'invoice';
$page_data['page_title'] = get_phrase('invoice');
$this->load->view('backend/index', $page_data);
}
function listado_de_reportes($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
if ($param1 == 'create')
{
$this->crud_model->create_report();
redirect(base_url(), 'refresh');
}
$page_data['page_title'] = "";
$page_data['page_name'] = 'listado_de_reportes';
$this->load->view('backend/index', $page_data);
}
function send_report()
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'send_report';
$page_data['page_title'] = get_phrase('teacher_report');
$this->load->view('backend/index', $page_data);
}
function noticeboard($param1 = '', $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'noticeboard';
$page_data['page_title'] = get_phrase('noticeboard');
$this->load->view('backend/index', $page_data);
}
function school_bus($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$page_data['transports'] = $this->db->get('transport')->result_array();
$page_data['page_name'] = 'school_bus';
$page_data['page_title'] = "";
$this->load->view('backend/index', $page_data);
}
function message($param1 = 'message_home', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
if ($param1 == 'send_new')
{
$this->session->set_flashdata('flash_message' , get_phrase('message_sent'));
$message_thread_code = $this->crud_model->send_new_private_message();
move_uploaded_file($_FILES["file_name"]["tmp_name"], "uploads/messages/" . $_FILES["file_name"]["name"]);
redirect(base_url() . 'student/message/message_read/' . $message_thread_code, 'refresh');
}
if ($param1 == 'send_reply')
{
$this->session->set_flashdata('flash_message' , get_phrase('reply_sent'));
$this->crud_model->send_reply_message($param2);
move_uploaded_file($_FILES["file_name"]["tmp_name"], "uploads/messages/" . $_FILES["file_name"]["name"]);
redirect(base_url() . 'student/message/message_read/' . $param2, 'refresh');
}
if ($param1 == 'message_read')
{
$page_data['current_message_thread_code'] = $param2;
$this->crud_model->mark_thread_messages_read($param2);
}
$page_data['infouser'] = $param2;
$page_data['message_inner_page_name'] = $param1;
$page_data['page_name'] = 'message';
$page_data['page_title'] = get_phrase('private_message');
$this->load->view('backend/index', $page_data);
}
function study_material($task = "", $document_id = "")
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page' , current_url());
redirect(base_url(), 'refresh');
}
$data['study_material_info'] = $this->crud_model->select_study_material_info_for_student();
$data['page_name'] = 'study_material';
$data['page_title'] = get_phrase('study_material');
$this->load->view('backend/index', $data);
}
function library($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$page_data['books'] = $this->db->get('book')->result_array();
$page_data['page_name'] = 'library';
$page_data['page_title'] = get_phrase('library');
$this->load->view('backend/index', $page_data);
}
function homeworkroom($param1 = '' , $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$page_data['homework_code'] = $param1;
$page_data['page_name'] = 'homework_room';
$page_data['page_title'] = get_phrase('homework');
$this->load->view('backend/index', $page_data);
}
function delivery($param1 = '', $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
if($param1 == 'file')
{
$data['homework_code'] = $param2;
$name = substr(md5(rand(0, 1000000)), 0, 7).$_FILES["file_name"]["name"];
$data['student_id'] = $this->session->userdata('login_user_id');
$data['date'] = date('m/d/Y H:i');
$data['class_id'] = $this->input->post('class_id');
$data['section_id'] = $this->input->post('section_id');
$data['file_name'] = $name;
$data['student_comment'] = $this->input->post('comment');
$data['subject_id'] = $this->input->post('subject_id');
$data['status'] = 1;
$this->db->insert('deliveries', $data);
move_uploaded_file($_FILES["file_name"]["tmp_name"], "uploads/homework_delivery/" . $name);
redirect(base_url() . 'student/homeworkroom/' . $param2, 'refresh');
}
if($param1 == 'text')
{
$data['homework_code'] = $param2;
$data['student_id'] = $this->session->userdata('login_user_id');
$data['date'] = date('m/d/Y H:i');
$data['class_id'] = $this->input->post('class_id');
$data['section_id'] = $this->input->post('section_id');
$data['homework_reply'] = $this->input->post('reply');
$data['student_comment'] = $this->input->post('comment');
$data['subject_id'] = $this->input->post('subject_id');
$data['status'] = 1;
$this->db->insert('deliveries', $data);
redirect(base_url() . 'student/homeworkroom/' . $param2, 'refresh');
}
}
function homework_file($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$homework_code = $this->db->get_where('homework', array('homework_id'))->row()->homework_code;
if ($param1 == 'upload')
{
$this->crud_model->upload_homework_file($param2);
redirect(base_url() . 'student/homeworkroom/file/' . $param2, 'refresh');
}
else if ($param1 == 'download')
{
$this->crud_model->download_homework_file($param2);
}
}
function forumroom($param1 = '' , $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$page_data['post_code'] = $param1;
$page_data['page_name'] = 'forum_room';
$page_data['page_title'] = get_phrase('forum');
$this->load->view('backend/index', $page_data);
}
function newsroom($param1 = '' , $param2 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
else if ($param1 == 'overview')
{
$page_data['room_page'] = 'news_overview';
$page_data['news_code'] = $param2;
}
$page_data['page_name'] = 'newsroom';
$page_data['page_title'] ="";
$page_data['page_title'] .= ": " . $this->db->get_where('news',array('news_code'=>$param2))->row()->title;
$this->load->view('backend/index', $page_data);
}
function create_report_message($code = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
$data['message'] = $this->input->post('message');
$data['report_code'] = $this->input->post('report_code');
$data['timestamp'] = date("d M, Y");
$data['sender_type'] = $this->session->userdata('login_type');
$data['sender_id'] = $this->session->userdata('login_user_id');
$this->db->insert('reporte_mensaje', $data);
}
function news_message($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
if ($param1 == 'add')
{
$this->crud_model->create_news_message($this->input->post('news_code'));
}
}
function read($code = "")
{
if ($this->session->userdata('student_login') != 1)
{
redirect(base_url(), 'refresh');
}
$page_data['page_name'] = 'read';
$page_data['page_title'] = get_phrase('noticeboard');
$page_data['code'] = $code;
$this->load->view('backend/index', $page_data);
}
function forum_message($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('student_login') != 1)
{
$this->session->set_userdata('last_page', current_url());
redirect(base_url(), 'refresh');
}
if ($param1 == 'add')
{
$this->crud_model->create_post_message($this->input->post('post_code'));
}
}
function forum($param1 = '', $param2 = '', $student_id = '')
{
if ($param1 == 'create')
{
$post_code = $this->crud_model->create_post();
redirect(base_url() . 'index.php?student/forumroom/post/' . $post_code , 'refresh');
}
$page_data['page_name'] = 'forum';
$page_data['page_title'] = get_phrase('forum');
$page_data['student_id'] = $student_id;
$this->load->view('backend/index', $page_data);
}
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,474 @@
<?php
// SimpleXLSX php class v0.4
// MS Excel 2007 workbooks reader
// Example:
// $xlsx = new SimpleXLSX('book.xlsx');
// print_r( $xlsx->rows() );
// Example 2:
// $xlsx = new SimpleXLSX('book.xlsx');
// print_r( $xlsx->rowsEx() );
// Example 3:
// $xlsx = new SimpleXLSX('book.xlsx');
// print_r( $xlsx->rows(2) ); // second worksheet
//
// 0.4 sheets(), sheetsCount(), unixstamp( $excelDateTime )
// 0.3 - fixed empty cells (Gonzo patch)
class SimpleXLSX {
private $sheets;
private $hyperlinks;
private $package;
private $sharedstrings;
// scheme
const SCHEMA_OFFICEDOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument';
const SCHEMA_RELATIONSHIP = 'http://schemas.openxmlformats.org/package/2006/relationships';
const SCHEMA_SHAREDSTRINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings';
const SCHEMA_WORKSHEETRELATION = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet';
public function __construct( $filename ) {
$this->_unzip( $filename );
$this->_parse();
}
public function sheets() {
return $this->sheets;
}
public function sheetsCount() {
return count($this->sheets);
}
public function worksheet( $worksheet_id ) {
if ( isset( $this->sheets[ $worksheet_id ] ) ) {
$ws = $this->sheets[ $worksheet_id ];
if (isset($ws->hyperlinks)) {
$this->hyperlinks = array();
foreach( $ws->hyperlinks->hyperlink as $hyperlink ) {
$this->hyperlinks[ (string) $hyperlink['ref'] ] = (string) $hyperlink['display'];
}
}
return $ws;
} else
throw new Exception('Worksheet '.$worksheet_id.' not found.');
}
/**
* Returns col and row number of a worksheet.
*
* @return array( $cols, $rows )
*/
public function dimension( $worksheet_id = 1 ) {
$ws = $this->worksheet($worksheet_id);
$ref = (string) $ws->dimension['ref'];
$d = explode(':', $ref);
$index = $this->_columnIndex( $d[1] );
return array( $index[0]+1, $index[1]+1);
}
/**
* Get file data.
*
* @param $worksheet_id: Worksheet's ID. 1-N
*/
public function rows( $worksheet_id = 1 ) {
$ws = $this->worksheet( $worksheet_id);
$rows = array();
$curR = 0;
$lastColumn = 0;
foreach ($ws->sheetData->row as $r=>$row) {
foreach ($row->c as $c) {
list($curC,) = $this->_columnIndex((string) $c['r']);
if ($curC > ($lastColumn+1)) {
// An increment has been found
for ($i=($lastColumn+1); $i<$curC; $i++) {
$rows[ $curR ][ $i ] = null;
}
}
$rows[ $curR ][ $curC ] = $this->value($c);
$lastColumn = $curC;
}
$curR++;
}
return $rows;
}
/**
* ?????
*/
public function rowsEx( $worksheet_id = 1 ) {
$rows = array();
$curR = 0;
if (($ws = $this->worksheet( $worksheet_id)) === false)
return false;
foreach ($ws->sheetData->row as $row) {
foreach ($row->c as $c) {
list($curC,) = $this->_columnIndex((string) $c['r']);
$rows[ $curR ][ $curC ] = array(
'name' => (string) $c['r'],
'value' => $this->value($c),
'href' => $this->href( $c ),
);
}
$curR++;
}
return $rows;
}
/**
*
* thx Gonzo
*/
protected function _columnIndex( $cell = 'A1' ) {
if (preg_match("/([A-Z]+)(\d+)/", $cell, $matches)) {
$col = $matches[1];
$row = $matches[2];
$colLen = strlen($col);
$index = 0;
for ($i = $colLen-1; $i >= 0; $i--)
$index += (ord($col{$i}) - 64) * pow(26, $colLen-$i-1);
return array($index-1, $row-1);
} else
throw new Exception("Invalid cell index.");
}
/**
* Grabs the value of a cell.
*/
public function value( $cell ) {
// Determine data type
$dataType = (string)$cell["t"];
switch ($dataType) {
case "s":
// Value is a shared string
if ((string)$cell->v != '') {
$value = $this->sharedstrings[intval($cell->v)];
} else {
$value = '';
}
break;
case "b":
// Value is boolean
$value = (string)$cell->v;
if ($value == '0') {
$value = false;
} else if ($value == '1') {
$value = true;
} else {
$value = (bool)$cell->v;
}
break;
case "inlineStr":
// Value is rich text inline
$value = $this->_parseRichText($cell->is);
break;
case "e":
// Value is an error message
if ((string)$cell->v != '') {
$value = (string)$cell->v;
} else {
$value = '';
}
break;
default:
// Value is a string
$value = (string)$cell->v;
// Check for numeric values
if (is_numeric($value) && $dataType != 's') {
if ($value == (int)$value) $value = (int)$value;
elseif ($value == (float)$value) $value = (float)$value;
elseif ($value == (double)$value) $value = (double)$value;
}
}
return $value;
}
/**
*
*/
public function href( $cell ) {
return isset( $this->hyperlinks[ (string) $cell['r'] ] ) ? $this->hyperlinks[ (string) $cell['r'] ] : '';
}
/**
* Opens file, decompresses it and loads into memory.
*
*/
protected function _unzip( $filename ) {
// Clear current file
$this->datasec = array();
// Package information
$this->package = array(
'filename' => $filename,
'mtime' => filemtime( $filename ),
'size' => filesize( $filename ),
'comment' => '',
'entries' => array()
);
// Read file
$oF = @fopen($filename, 'rb');
if( $oF===false )
{
throw new Exception('Could not open file: "'.$filename.'"' );
}
$vZ = @fread($oF, $this->package['size']);
fclose($oF);
// Cut end of central directory
$aE = explode("\x50\x4b\x05\x06", $vZ);
// Normal way
$aP = unpack('x16/v1CL', $aE[1]);
$this->package['comment'] = substr($aE[1], 18, $aP['CL']);
// Translates end of line from other operating systems
$this->package['comment'] = strtr($this->package['comment'], array("\r\n" => "\n", "\r" => "\n"));
// Cut the entries from the central directory
$aE = explode("\x50\x4b\x01\x02", $vZ);
// Explode to each part
$aE = explode("\x50\x4b\x03\x04", $aE[0]);
// Shift out spanning signature or empty entry
array_shift($aE);
// Loop through the entries
foreach ($aE as $vZ) {
$aI = array();
$aI['E'] = 0;
$aI['EM'] = '';
// Retrieving local file header information
// $aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
$aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL/v1EFL', $vZ);
// Check if data is encrypted
// $bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE;
$bE = false;
$nF = $aP['FNL'];
$mF = $aP['EFL'];
// Special case : value block after the compressed data
if ($aP['GPF'] & 0x0008) {
$aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
$aP['CRC'] = $aP1['CRC'];
$aP['CS'] = $aP1['CS'];
$aP['UCS'] = $aP1['UCS'];
$vZ = substr($vZ, 0, -12);
}
// Getting stored filename
$aI['N'] = substr($vZ, 26, $nF);
if (substr($aI['N'], -1) == '/') {
// is a directory entry - will be skipped
continue;
}
// Truncate full filename in path and filename
$aI['P'] = dirname($aI['N']);
$aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
$aI['N'] = basename($aI['N']);
$vZ = substr($vZ, 26 + $nF + $mF);
if (strlen($vZ) != $aP['CS']) {
$aI['E'] = 1;
$aI['EM'] = 'Compressed size is not equal with the value in header information.';
} else {
if ($bE) {
$aI['E'] = 5;
$aI['EM'] = 'File is encrypted, which is not supported from this class.';
} else {
switch($aP['CM']) {
case 0: // Stored
// Here is nothing to do, the file ist flat.
break;
case 8: // Deflated
$vZ = gzinflate($vZ);
break;
case 12: // BZIP2
if (! extension_loaded('bz2')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@dl('php_bz2.dll');
} else {
@dl('bz2.so');
}
}
if (extension_loaded('bz2')) {
$vZ = bzdecompress($vZ);
} else {
$aI['E'] = 7;
$aI['EM'] = "PHP BZIP2 extension not available.";
}
break;
default:
$aI['E'] = 6;
$aI['EM'] = "De-/Compression method {$aP['CM']} is not supported.";
}
if (! $aI['E']) {
if ($vZ === FALSE) {
$aI['E'] = 2;
$aI['EM'] = 'Decompression of data failed.';
} else {
if (strlen($vZ) != $aP['UCS']) {
$aI['E'] = 3;
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
} else {
if (crc32($vZ) != $aP['CRC']) {
$aI['E'] = 4;
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
}
}
}
}
}
}
$aI['D'] = $vZ;
// DOS to UNIX timestamp
$aI['T'] = mktime(($aP['FT'] & 0xf800) >> 11,
($aP['FT'] & 0x07e0) >> 5,
($aP['FT'] & 0x001f) << 1,
($aP['FD'] & 0x01e0) >> 5,
($aP['FD'] & 0x001f),
(($aP['FD'] & 0xfe00) >> 9) + 1980);
//$this->Entries[] = &new SimpleUnzipEntry($aI);
$this->package['entries'][] = array(
'data' => $aI['D'],
'error' => $aI['E'],
'error_msg' => $aI['EM'],
'name' => $aI['N'],
'path' => $aI['P'],
'time' => $aI['T']
);
} // end for each entries
}
public function getPackage() {
return $this->package;
}
public function getEntryData( $name ) {
$dir = dirname( $name );
$name = basename( $name );
foreach( $this->package['entries'] as $entry)
if ( $entry['path'] == $dir && $entry['name'] == $name)
return $entry['data'];
}
public function unixstamp( $excelDateTime ) {
$d = floor( $excelDateTime ); // seconds since 1900
$t = $excelDateTime - $d;
return ($d > 0) ? ( $d - 25569 ) * 86400 + $t * 86400 : $t * 86400;
}
protected function _parse() {
// Document data holders
$this->sharedstrings = array();
$this->sheets = array();
// Read relations and search for officeDocument
$relations = simplexml_load_string( $this->getEntryData("_rels/.rels") );
foreach ($relations->Relationship as $rel) {
if ($rel["Type"] == SimpleXLSX::SCHEMA_OFFICEDOCUMENT) {
// Found office document! Read relations for workbook...
$workbookRelations = simplexml_load_string($this->getEntryData( dirname($rel["Target"]) . "/_rels/" . basename($rel["Target"]) . ".rels") );
$workbookRelations->registerXPathNamespace("rel", SimpleXLSX::SCHEMA_RELATIONSHIP);
// Read shared strings
$sharedStringsPath = $workbookRelations->xpath("rel:Relationship[@Type='" . SimpleXLSX::SCHEMA_SHAREDSTRINGS . "']");
$sharedStringsPath = (string)$sharedStringsPath[0]['Target'];
$xmlStrings = simplexml_load_string($this->getEntryData( dirname($rel["Target"]) . "/" . $sharedStringsPath) );
if (isset($xmlStrings) && isset($xmlStrings->si)) {
foreach ($xmlStrings->si as $val) {
if (isset($val->t)) {
$this->sharedstrings[] = (string)$val->t;
} elseif (isset($val->r)) {
$this->sharedstrings[] = $this->_parseRichText($val);
}
}
}
// Loop relations for workbook and extract sheets...
foreach ($workbookRelations->Relationship as $workbookRelation) {
if ($workbookRelation["Type"] == SimpleXLSX::SCHEMA_WORKSHEETRELATION) {
$this->sheets[ str_replace( 'rId', '', (string) $workbookRelation["Id"]) ] =
simplexml_load_string( $this->getEntryData( dirname($rel["Target"]) . "/" . dirname($workbookRelation["Target"]) . "/" . basename($workbookRelation["Target"])) );
}
}
break;
}
}
// Sort sheets
ksort($this->sheets);
}
protected function _parseRichText($is = null) {
$value = array();
if (isset($is->t)) {
$value[] = (string)$is->t;
} else {
foreach ($is->r as $run) {
$value[] = (string)$run->t;
}
}
return implode(' ', $value);
}
}

View File

@ -0,0 +1,113 @@
<?php
class SmsGateway {
static $baseUrl = "https://smsgateway.me";
function __construct($email,$password) {
$this->email = $email;
$this->password = $password;
}
function createContact ($name,$number) {
return $this->makeRequest('/api/v3/contacts/create','POST',['name' => $name, 'number' => $number]);
}
function getContacts ($page=1) {
return $this->makeRequest('/api/v3/contacts','GET',['page' => $page]);
}
function getContact ($id) {
return $this->makeRequest('/api/v3/contacts/view/'.$id,'GET');
}
function getDevices ($page=1)
{
return $this->makeRequest('/api/v3/devices','GET',['page' => $page]);
}
function getDevice ($id)
{
return $this->makeRequest('/api/v3/devices/view/'.$id,'GET');
}
function getMessages($page=1)
{
return $this->makeRequest('/api/v3/messages','GET',['page' => $page]);
}
function getMessage($id)
{
return $this->makeRequest('/api/v3/messages/view/'.$id,'GET');
}
function sendMessageToNumber($to, $message, $device, $options=[]) {
$query = array_merge(['number'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST',$query);
}
function sendMessageToManyNumbers ($to, $message, $device, $options=[]) {
$query = array_merge(['number'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
function sendMessageToContact ($to, $message, $device, $options=[]) {
$query = array_merge(['contact'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
function sendMessageToManyContacts ($to, $message, $device, $options=[]) {
$query = array_merge(['contact'=>$to, 'message'=>$message, 'device' => $device], $options);
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
function sendManyMessages ($data) {
$query['data'] = $data;
return $this->makeRequest('/api/v3/messages/send','POST', $query);
}
private function makeRequest ($url, $method, $fields=[]) {
$fields['email'] = $this->email;
$fields['password'] = $this->password;
$url = smsGateway::$baseUrl.$url;
$fieldsString = http_build_query($fields);
$ch = curl_init();
if($method == 'POST')
{
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fieldsString);
}
else
{
$url .= '?'.$fieldsString;
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER , false); // we want headers
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec ($ch);
$return['response'] = json_decode($result,true);
if($return['response'] == false)
$return['response'] = $result;
$return['status'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
return $return;
}
}
?>

11
application/core/index.html Executable file
View File

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

View File

@ -0,0 +1,234 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Output Cache Helper
*
* Utility functions for working with CodeIgniter's output cache.
* All code based on or directly copied from CodeIgniter.
*
* @category Helpers
* @author Steven Benner (http://stevenbenner.com/)
* @link https://github.com/stevenbenner/codeigniter-cache-helper
* @license MIT License
* @version 1.4.2
*/
/**
* Get Cache Folder
*
* Gets the path to the application cache folder.
*
* @return string Path to the cache folder.
*/
if ( ! function_exists('get_cache_folder'))
{
function get_cache_folder()
{
$CI =& get_instance();
$path = $CI->config->item('cache_path');
$cache_path = ($path == '') ? APPPATH . 'cache/' : $path;
return $cache_path;
}
}
/**
* Get Cache File
*
* Gets the path to a cache file for the specified uri_string().
*
* @param string $uri_string Full uri_string() of the target page (e.g. 'blog/comments/123').
* @return string Path to the cache file.
*/
if ( ! function_exists('get_cache_file'))
{
function get_cache_file($uri_string)
{
$CI =& get_instance();
$uri = $CI->config->item('base_url') .
$CI->config->item('index_page') .
$uri_string;
return get_cache_folder() . md5($uri);
}
}
/**
* Get All Cache Files
*
* Gets the path to every cache file currently saved.
*
* @return array get_dir_file_info() of cache files.
*/
if ( ! function_exists('get_all_cache_files'))
{
function get_all_cache_files()
{
$CI =& get_instance();
$CI->load->helper('file');
return get_dir_file_info(get_cache_folder());
}
}
/**
* Delete Cache File
*
* Evicts the output cache for the targeted page.
*
* @param string $uri_string Full uri_string() of the target page (e.g. 'blog/comments/123').
* @return boolean TRUE if the cache file was removed, FALSE if it was not.
*/
if ( ! function_exists('delete_cache'))
{
function delete_cache($uri_string)
{
$cache_path = get_cache_file($uri_string);
if (file_exists($cache_path))
{
return unlink($cache_path);
}
else
{
return TRUE;
}
}
}
/**
* Delete All Cache
*
* Evicts the output cache for all pages currently cached.
*
* @return void
*/
if ( ! function_exists('delete_all_cache'))
{
function delete_all_cache()
{
$cache_files = get_all_cache_files();
foreach ($cache_files as $file)
{
// only delete files with names that are 32 characters in length (MD5)
if (strlen($file['name']) === 32 && is_really_writable($file['server_path']))
{
@unlink($file['server_path']);
}
}
}
}
/**
* Delete Expired Cache
*
* Delete all expired cache files. This is a fairly expensive function so it
* should not be called on every hit.
*
* @return void
*/
if ( ! function_exists('delete_expired_cache'))
{
function delete_expired_cache()
{
$CI =& get_instance();
$CI->load->helper('file');
$files = get_dir_file_info(get_cache_folder());
foreach ($files as $file)
{
if (strlen($file['name']) !== 32)
{
continue;
}
if ( ! $fp = @fopen($file['server_path'], FOPEN_READ))
{
continue;
}
flock($fp, LOCK_SH);
$time_str = '';
while (($char = fgetc($fp)) !== FALSE)
{
if ($char === 'T')
{
break;
}
$time_str .= $char;
}
flock($fp, LOCK_UN);
fclose($fp);
if (ctype_digit($time_str) && time() >= (int)$time_str)
{
if (is_really_writable($file['server_path']))
{
@unlink($file['server_path']);
}
}
}
}
}
/**
* Get Cache Expiration
*
* Gets the expiration time for a cache file. Time strings are in time() format.
*
* @param string $uri_string Full uri_string() of the target page.
* @return mixed Time from the cache file or FALSE if there was a problem.
*/
if ( ! function_exists('get_cache_expiration'))
{
function get_cache_expiration($uri_string)
{
$cache_path = get_cache_file($uri_string);
if ( ! @file_exists($cache_path))
{
return FALSE;
}
if ( ! $fp = @fopen($cache_path, FOPEN_READ))
{
return FALSE;
}
flock($fp, LOCK_SH);
$time_str = '';
while (($char = fgetc($fp)) !== FALSE)
{
if ($char === 'T')
{
break;
}
$time_str .= $char;
}
flock($fp, LOCK_UN);
fclose($fp);
if (ctype_digit($time_str))
{
return (int)$time_str;
}
else
{
return FALSE;
}
}
}
/* End of file cache_helper.php */
/* Location: ./application/helpers/cache_helper.php */

11
application/helpers/index.html Executable file
View File

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

View File

@ -0,0 +1,51 @@
<?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
*/
if ( ! function_exists('get_phrase'))
{
function get_phrase($phrase = '') {
$CI =& get_instance();
$CI->load->database();
$current_language = $CI->db->get_where('settings' , array('type' => 'language'))->row()->description;
if ( $current_language == '') {
$current_language = 'english';
$CI->session->set_userdata('current_language' , $current_language);
}
/** insert blank phrases initially and populating the language db ***/
$check_phrase = $CI->db->get_where('language' , array('phrase' => $phrase))->row()->phrase;
if ( $check_phrase != $phrase)
$CI->db->insert('language' , array('phrase' => $phrase));
// query for finding the phrase from `language` table
$query = $CI->db->get_where('language' , array('phrase' => $phrase));
$row = $query->row();
// return the current sessioned language field of according phrase, else return uppercase spaced word
if (isset($row->$current_language) && $row->$current_language !="")
return $row->$current_language;
else
return ucwords(str_replace('_',' ',$phrase));
}
}
// ------------------------------------------------------------------------
/* End of file language_helper.php */
/* Location: ./system/helpers/language_helper.php */

11
application/hooks/index.html Executable file
View File

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

11
application/index.html Executable file
View File

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

View File

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

11
application/language/index.html Executable file
View File

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

307
application/libraries/Paypal.php Executable file
View File

@ -0,0 +1,307 @@
<?php
/*******************************************************************************
* PHP Paypal IPN Integration Class
*******************************************************************************
* Author: Micah Carrick
* Email: email@micahcarrick.com
* Website: http://www.micahcarrick.com
*
* File: paypal.class.php
* Version: 1.3.0
* Copyright: (c) 2005 - Micah Carrick
* You are free to use, distribute, and modify this software
* under the terms of the GNU General Public License. See the
* included license.txt file.
*
*******************************************************************************
* VERION HISTORY:
* v1.3.0 [10.10.2005] - Fixed it so that single quotes are handled the
* right way rather than simple stripping them. This
* was needed because the user could still put in
* quotes.
*
* v1.2.1 [06.05.2005] - Fixed typo from previous fix :)
*
* v1.2.0 [05.31.2005] - Added the optional ability to remove all quotes
* from the paypal posts. The IPN will come back
* invalid sometimes when quotes are used in certian
* fields.
*
* v1.1.0 [05.15.2005] - Revised the form output in the submit_paypal_post
* method to allow non-javascript capable browsers
* to provide a means of manual form submission.
*
* v1.0.0 [04.16.2005] - Initial Version
*
*******************************************************************************
* DESCRIPTION:
*
* NOTE: See www.micahcarrick.com for the most recent version of this class
* along with any applicable sample files and other documentaion.
*
* This file provides a neat and simple method to interface with paypal and
* The paypal Instant Payment Notification (IPN) interface. This file is
* NOT intended to make the paypal integration "plug 'n' play". It still
* requires the developer (that should be you) to understand the paypal
* process and know the variables you want/need to pass to paypal to
* achieve what you want.
*
* This class handles the submission of an order to paypal aswell as the
* processing an Instant Payment Notification.
*
* This code is based on that of the php-toolkit from paypal. I've taken
* the basic principals and put it in to a class so that it is a little
* easier--at least for me--to use. The php-toolkit can be downloaded from
* http://sourceforge.net/projects/paypal.
*
* To submit an order to paypal, have your order form POST to a file with:
*
* $p = new Paypal;
* $p->add_field('business', 'somebody@domain.com');
* $p->add_field('first_name', $_POST['first_name']);
* ... (add all your fields in the same manor)
* $p->submit_paypal_post();
*
* To process an IPN, have your IPN processing file contain:
*
* $p = new Paypal;
* if ($p->validate_ipn()) {
* ... (IPN is verified. Details are in the ipn_data() array)
* }
*
*
* In case you are new to paypal, here is some information to help you:
*
* 1. Download and read the Merchant User Manual and Integration Guide from
* http://www.paypal.com/en_US/pdf/integration_guide.pdf. This gives
* you all the information you need including the fields you can pass to
* paypal (using add_field() with this class) aswell as all the fields
* that are returned in an IPN post (stored in the ipn_data() array in
* this class). It also diagrams the entire transaction process.
*
* 2. Create a "sandbox" account for a buyer and a seller. This is just
* a test account(s) that allow you to test your site from both the
* seller and buyer perspective. The instructions for this is available
* at https://developer.paypal.com/ as well as a great forum where you
* can ask all your paypal integration questions. Make sure you follow
* all the directions in setting up a sandbox test environment, including
* the addition of fake bank accounts and credit cards.
*
*******************************************************************************
*/
class Paypal {
var $last_error; // holds the last error encountered
var $ipn_log; // bool: log IPN results to text file?
var $ipn_log_file; // filename of the IPN log
var $ipn_response; // holds the IPN response from paypal
var $ipn_data = array(); // array contains the POST values for IPN
var $fields = array(); // array holds the fields to submit to paypal
function Paypal() {
// initialization constructor. Called when class is created.
//$this->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
$this->last_error = '';
$this->ipn_log_file = '.ipn_results.log';
$this->ipn_log = true;
$this->ipn_response = '';
// populate $fields array with a few default values. See the paypal
// documentation for a list of fields and their data types. These defaul
// values can be overwritten by the calling script.
$this->add_field('rm','2'); // Return method = POST
$this->add_field('cmd','_xclick');
}
function add_field($field, $value) {
// adds a key=>value pair to the fields array, which is what will be
// sent to paypal as POST variables. If the value is already in the
// array, it will be overwritten.
$this->fields["$field"] = $value;
}
function submit_paypal_post() {
// this function actually generates an entire HTML page consisting of
// a form with hidden elements which is submitted to paypal via the
// BODY element's onLoad attribute. We do this so that you can validate
// any POST vars from you custom form before submitting to paypal. So
// basically, you'll have your own form which is submitted to your script
// to validate the data, which in turn calls this function to create
// another hidden form and submit to paypal.
// The user will briefly see a message on the screen that reads:
// "Please wait, your order is being processed..." and then immediately
// is redirected to paypal.
echo "<html>\n";
//echo "<head><title>Processing Payment...</title></head>\n";
echo "<body onLoad=\"document.forms['paypal_form'].submit();\">\n";
//echo "<center><h3>";
//echo " Redirecting to the paypal.</h3></center>\n";
echo "<form method=\"post\" name=\"paypal_form\" ";
echo "action=\"".$this->paypal_url."\">\n";
foreach ($this->fields as $name => $value) {
echo "<input type=\"hidden\" name=\"$name\" value=\"$value\"/>\n";
}
echo "</form>\n";
echo "</body></html>\n";
}
function validate_ipn() {
# STEP 1: Read POST data
# reading posted data from directly from $_POST causes serialization
# issues with array data in POST
# reading raw POST data from input stream instead.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval)
{
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
# read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc'))
{
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value)
{
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1)
{
$value = urlencode(stripslashes($value));
}
else
{
$value = urlencode($value);
}
$req .= "&$key=$value";
}
# STEP 2: Post IPN data back to paypal to validate
$ch = curl_init($this->paypal_url);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
# In wamp like environments that do not come bundled with root authority certificates,
# please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
# of the certificate as shown below.
# curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
curl_close($ch);
$this->write_log('curl error');
exit;
}
curl_close($ch);
# STEP 3: Inspect IPN validation result and act accordingly
if (strcmp ($res, "VERIFIED") == 0)
{
return true;
# assign posted variables to local variables
#$uniqid = $_POST['custom'];
#$item_number = $_POST['item_number'];
#$payment_status = $_POST['payment_status'];
#$payment_amount = $_POST['mc_gross'];
#$payment_currency = $_POST['mc_currency'];
#$txn_id = $_POST['txn_id'];
#$txn_type = $_POST['txn_type'];
#$receiver_email = $_POST['receiver_email'];
#$payer_email = $_POST['payer_email'];
# check whether the payment_status is Completed
# check that txn_id has not been previously processed
# check that receiver_email is your Primary PayPal email
# check that payment_amount/payment_currency are correct
}
else if (strcmp ($res, "INVALID") == 0)
{
return false;
}
}
function log_ipn_results($success) {
if (!$this->ipn_log) return; // is logging turned off?
// Timestamp
$text = '['.date('m/d/Y g:i A').'] - ';
// Success or failure being logged?
if ($success) $text .= "SUCCESS!\n";
else $text .= 'FAIL: '.$this->last_error."\n";
// Log the POST variables
$text .= "IPN POST Vars from Paypal:\n";
foreach ($this->ipn_data as $key=>$value) {
$text .= "$key=$value, ";
}
// Log the response from the paypal server
$text .= "\nIPN Response from Paypal Server:\n ".$this->ipn_response;
// Write to log
$fp=fopen($this->ipn_log_file,'a');
fwrite($fp, $text . "\n\n");
fclose($fp); // close file
}
function dump_fields() {
// Used for debugging, this function will output all the field/value pairs
// that are currently defined in the instance of the class using the
// add_field() function.
echo "<h3>Paypal->dump_fields() Output:</h3>";
echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">
<tr>
<td bgcolor=\"black\"><b><font color=\"white\">Field Name</font></b></td>
<td bgcolor=\"black\"><b><font color=\"white\">Value</font></b></td>
</tr>";
ksort($this->fields);
foreach ($this->fields as $key => $value) {
echo "<tr><td>$key</td><td>".urldecode($value)."&nbsp;</td></tr>";
}
echo "</table><br>";
}
}

View File

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

View File

@ -0,0 +1,545 @@
<?php
/*
* Author: Neuman Vong neuman@twilio.com
* License: http://creativecommons.org/licenses/MIT/ MIT
* Link: https://twilio-php.readthedocs.org/en/latest/
*/
function Services_Twilio_autoload($className)
{
if (substr($className, 0, 15) != 'Services_Twilio' && substr($className, 0, 26) != 'TaskRouter_Services_Twilio') {
return false;
}
$file = str_replace('_', '/', $className);
$file = str_replace('Services/', '', $file);
return include dirname(__FILE__) . "/$file.php";
}
spl_autoload_register('Services_Twilio_autoload');
/**
* Base client class
*/
abstract class Base_Services_Twilio extends Services_Twilio_Resource
{
const USER_AGENT = 'twilio-php/3.13.1';
protected $http;
protected $last_response;
protected $retryAttempts;
protected $version;
protected $versions = array('2010-04-01');
public function __construct(
$sid,
$token,
$version = null,
Services_Twilio_TinyHttp $_http = null,
$retryAttempts = 1
)
{
$this->version = in_array($version, $this->versions) ? $version : end($this->versions);
if (null === $_http) {
if (!in_array('openssl', get_loaded_extensions())) {
throw new Services_Twilio_HttpException("The OpenSSL extension is required but not currently enabled. For more information, see http://php.net/manual/en/book.openssl.php");
}
if (in_array('curl', get_loaded_extensions())) {
$_http = new Services_Twilio_TinyHttp(
$this->_getBaseUri(),
array(
"curlopts" => array(
CURLOPT_USERAGENT => self::qualifiedUserAgent(phpversion()),
CURLOPT_HTTPHEADER => array('Accept-Charset: utf-8'),
),
)
);
} else {
$_http = new Services_Twilio_HttpStream(
$this->_getBaseUri(),
array(
"http_options" => array(
"http" => array(
"user_agent" => self::qualifiedUserAgent(phpversion()),
"header" => "Accept-Charset: utf-8\r\n",
),
"ssl" => array(
'verify_peer' => true,
'verify_depth' => 5,
),
),
)
);
}
}
$_http->authenticate($sid, $token);
$this->http = $_http;
$this->retryAttempts = $retryAttempts;
}
/**
* Build a query string from query data
*
* :param array $queryData: An associative array of keys and values. The
* values can be a simple type or a list, in which case the list is
* converted to multiple query parameters with the same key.
* :param string $numericPrefix:
* :param string $queryStringStyle: Determine how to build the url
* - strict: Build a standards compliant query string without braces (can be hacked by using braces in key)
* - php: Build a PHP compatible query string with nested array syntax
* :return: The encoded query string
* :rtype: string
*/
public static function buildQuery($queryData, $numericPrefix = '')
{
$query = '';
// Loop through all of the $query_data
foreach ($queryData as $key => $value) {
// If the key is an int, add the numeric_prefix to the beginning
if (is_int($key)) {
$key = $numericPrefix . $key;
}
// If the value is an array, we will end up recursing
if (is_array($value)) {
// Loop through the values
foreach ($value as $value2) {
// Add an arg_separator if needed
if ($query !== '') {
$query .= '&';
}
// Recurse
$query .= self::buildQuery(array($key => $value2), $numericPrefix);
}
} else {
// Add an arg_separator if needed
if ($query !== '') {
$query .= '&';
}
// Add the key and the urlencoded value (as a string)
$query .= $key . '=' . urlencode((string)$value);
}
}
return $query;
}
/**
* Construct a URI based on initial path, query params, and paging
* information
*
* We want to use the query params, unless we have a next_page_uri from the
* API.
*
* :param string $path: The request path (may contain query params if it's
* a next_page_uri)
* :param array $params: Query parameters to use with the request
* :param boolean $full_uri: Whether the $path contains the full uri
*
* :return: the URI that should be requested by the library
* :returntype: string
*/
public static function getRequestUri($path, $params, $full_uri = false)
{
$json_path = $full_uri ? $path : "$path.json";
if (!$full_uri && !empty($params)) {
$query_path = $json_path . '?' . http_build_query($params, '', '&');
} else {
$query_path = $json_path;
}
return $query_path;
}
/**
* Fully qualified user agent with the current PHP Version.
*
* :return: the user agent
* :rtype: string
*/
public static function qualifiedUserAgent($php_version)
{
return self::USER_AGENT . " (php $php_version)";
}
/**
* POST to the resource at the specified path.
*
* :param string $path: Path to the resource
* :param array $params: Query string parameters
*
* :return: The object representation of the resource
* :rtype: object
*/
public function createData($path, $params = array(), $full_uri = false)
{
if (!$full_uri) {
$path = "$path.json";
}
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$response = $this->http->post(
$path, $headers, self::buildQuery($params, '')
);
return $this->_processResponse($response);
}
/**
* DELETE the resource at the specified path.
*
* :param string $path: Path to the resource
* :param array $params: Query string parameters
*
* :return: The object representation of the resource
* :rtype: object
*/
public function deleteData($path, $params = array())
{
$uri = self::getRequestUri($path, $params);
return $this->_makeIdempotentRequest(array($this->http, 'delete'),
$uri, $this->retryAttempts);
}
/**
* Get the retry attempt limit used by the rest client
*
* :return: the number of retry attempts
* :rtype: int
*/
public function getRetryAttempts()
{
return $this->retryAttempts;
}
/**
* Get the api version used by the rest client
*
* :return: the API version in use
* :returntype: string
*/
public function getVersion()
{
return $this->version;
}
/**
* GET the resource at the specified path.
*
* :param string $path: Path to the resource
* :param array $params: Query string parameters
* :param boolean $full_uri: Whether the full URI has been passed as an
* argument
*
* :return: The object representation of the resource
* :rtype: object
*/
public function retrieveData($path, $params = array(),
$full_uri = false
)
{
$uri = static::getRequestUri($path, $params, $full_uri);
return $this->_makeIdempotentRequest(array($this->http, 'get'),
$uri, $this->retryAttempts);
}
/**
* Get the base URI for this client.
*
* :return: base URI
* :rtype: string
*/
protected function _getBaseUri()
{
return 'https://api.twilio.com';
}
/**
* Helper method for implementing request retry logic
*
* :param array $callable: The function that makes an HTTP request
* :param string $uri: The URI to request
* :param int $retriesLeft: Number of times to retry
*
* :return: The object representation of the resource
* :rtype: object
*/
protected function _makeIdempotentRequest($callable, $uri, $retriesLeft)
{
$response = call_user_func_array($callable, array($uri));
list($status, $headers, $body) = $response;
if ($status >= 500 && $retriesLeft > 0) {
return $this->_makeIdempotentRequest($callable, $uri, $retriesLeft - 1);
} else {
return $this->_processResponse($response);
}
}
/**
* Convert the JSON encoded resource into a PHP object.
*
* :param array $response: 3-tuple containing status, headers, and body
*
* :return: PHP object decoded from JSON
* :rtype: object
* :throws: A :php:class:`Services_Twilio_RestException` if the Response is
* in the 300-500 range of status codes.
*/
private function _processResponse($response)
{
list($status, $headers, $body) = $response;
if ($status === 204) {
return true;
}
$decoded = json_decode($body);
if ($decoded === null) {
throw new Services_Twilio_RestException(
$status,
'Could not decode response body as JSON. ' .
'This likely indicates a 500 server error'
);
}
if (200 <= $status && $status < 300) {
$this->last_response = $decoded;
return $decoded;
}
throw new Services_Twilio_RestException(
$status,
isset($decoded->message) ? $decoded->message : '',
isset($decoded->code) ? $decoded->code : null,
isset($decoded->more_info) ? $decoded->more_info : null
);
}
}
/**
* Create a client to talk to the Twilio Rest API.
*
*
* :param string $sid: Your Account SID
* :param string $token: Your Auth Token from `your dashboard
* <https://www.twilio.com/user/account>`_
* :param string $version: API version to use
* :param $_http: A HTTP client for making requests.
* :type $_http: :php:class:`Services_Twilio_TinyHttp`
* :param int $retryAttempts:
* Number of times to retry failed requests. Currently only idempotent
* requests (GET's and DELETE's) are retried.
*
* Here's an example:
*
* .. code-block:: php
*
* require('Services/Twilio.php');
* $client = new Services_Twilio('AC123', '456bef', null, null, 3);
* // Take some action with the client, etc.
*/
class Services_Twilio extends Base_Services_Twilio
{
CONST URI = 'https://api.twilio.com';
protected $versions = array('2008-08-01', '2010-04-01');
public function __construct(
$sid,
$token,
$version = null,
Services_Twilio_TinyHttp $_http = null,
$retryAttempts = 1
)
{
parent::__construct($sid, $token, $version, $_http, $retryAttempts);
$this->accounts = new Services_Twilio_Rest_Accounts($this, "/{$this->version}/Accounts");
$this->account = $this->accounts->get($sid);
}
}
/**
* Create a client to talk to the Twilio TaskRouter API.
*
*
* :param string $sid: Your Account SID
* :param string $token: Your Auth Token from `your dashboard
* <https://www.twilio.com/user/account>`_
* :param string $workspaceSid:
* Workspace SID to work with
* :param string $version: API version to use
* :param $_http: A HTTP client for making requests.
* :type $_http: :php:class:`Services_Twilio_TinyHttp`
* :param int $retryAttempts:
* Number of times to retry failed requests. Currently only idempotent
* requests (GET's and DELETE's) are retried.
*
* Here's an example:
*
* .. code-block:: php
*
* require('Services/Twilio.php');
* $client = new TaskRouter_Services_Twilio('AC123', '456bef', null, null, 3);
* // Take some action with the client, etc.
*/
class TaskRouter_Services_Twilio extends Base_Services_Twilio
{
protected $versions = array('v1');
private $accountSid;
public function __construct(
$sid,
$token,
$workspaceSid,
$version = null,
Services_Twilio_TinyHttp $_http = null,
$retryAttempts = 1
)
{
parent::__construct($sid, $token, $version, $_http, $retryAttempts);
$this->workspaces = new Services_Twilio_Rest_TaskRouter_Workspaces($this, "/{$this->version}/Workspaces");
$this->workspace = $this->workspaces->get($workspaceSid);
$this->accountSid = $sid;
}
/**
* Construct a URI based on initial path, query params, and paging
* information
*
* We want to use the query params, unless we have a next_page_uri from the
* API.
*
* :param string $path: The request path (may contain query params if it's
* a next_page_uri)
* :param array $params: Query parameters to use with the request
* :param boolean $full_uri: Whether the $path contains the full uri
*
* :return: the URI that should be requested by the library
* :returntype: string
*/
public static function getRequestUri($path, $params, $full_uri = false)
{
if (!$full_uri && !empty($params)) {
$query_path = $path . '?' . http_build_query($params, '', '&');
} else {
$query_path = $path;
}
return $query_path;
}
public static function createWorkspace($sid, $token, $friendlyName, array $params = array(), Services_Twilio_TinyHttp $_http = null)
{
$taskrouterClient = new TaskRouter_Services_Twilio($sid, $token, null, null, $_http);
return $taskrouterClient->workspaces->create($friendlyName, $params);
}
public function getTaskQueuesStatistics(array $params = array())
{
return $this->retrieveData("/{$this->version}/Workspaces/{$this->workspace->sid}/TaskQueues/Statistics", $params);
}
public function getTaskQueueStatistics($taskQueueSid, array $params = array())
{
return $this->retrieveData("/{$this->version}/Workspaces/{$this->workspace->sid}/TaskQueues/{$taskQueueSid}/Statistics", $params);
}
public function getWorkersStatistics(array $params = array())
{
return $this->retrieveData("/{$this->version}/Workspaces/{$this->workspace->sid}/Workers/Statistics", $params);
}
public function getWorkerStatistics($workerSid, array $params = array())
{
return $this->retrieveData("/{$this->version}/Workspaces/{$this->workspace->sid}/Workers/{$workerSid}/Statistics", $params);
}
public function getWorkflowStatistics($workflowSid, array $params = array())
{
return $this->retrieveData("/{$this->version}/Workspaces/{$this->workspace->sid}/Workflows/{$workflowSid}/Statistics", $params);
}
public function getWorkspaceStatistics(array $params = array())
{
return $this->retrieveData("/{$this->version}/Workspaces/{$this->workspace->sid}/Statistics", $params);
}
protected function _getBaseUri()
{
return 'https://taskrouter.twilio.com';
}
}
/**
* Create a client to talk to the Twilio Lookups API.
*
*
* :param string $sid: Your Account SID
* :param string $token: Your Auth Token from `your dashboard
* <https://www.twilio.com/user/account>`_
* :param string $version: API version to use
* :param $_http: A HTTP client for making requests.
* :type $_http: :php:class:`Services_Twilio_TinyHttp`
* :param int $retryAttempts:
* Number of times to retry failed requests. Currently only idempotent
* requests (GET's and DELETE's) are retried.
*
* Here's an example:
*
* .. code-block:: php
*
* require('Services/Twilio.php');
* $client = new Lookups_Services_Twilio('AC123', '456bef', null, null, 3);
* // Take some action with the client, etc.
*/
class Lookups_Services_Twilio extends Base_Services_Twilio
{
protected $versions = array('v1');
private $accountSid;
public function __construct(
$sid,
$token,
$version = null,
Services_Twilio_TinyHttp $_http = null,
$retryAttempts = 1
)
{
parent::__construct($sid, $token, $version, $_http, $retryAttempts);
$this->accountSid = $sid;
$this->phone_numbers = new Services_Twilio_Rest_Lookups_PhoneNumbers($this, "/{$this->version}/PhoneNumbers");
}
/**
* Construct a URI based on initial path, query params, and paging
* information
*
* We want to use the query params, unless we have a next_page_uri from the
* API.
*
* :param string $path: The request path (may contain query params if it's
* a next_page_uri)
* :param array $params: Query parameters to use with the request
* :param boolean $full_uri: Whether the $path contains the full uri
*
* :return: the URI that should be requested by the library
* :returntype: string
*/
public static function getRequestUri($path, $params, $full_uri = false)
{
if (!$full_uri && !empty($params)) {
$query_path = $path . '?' . http_build_query($params, '', '&');
} else {
$query_path = $path;
}
return $query_path;
}
/**
* Get the base URI for this client.
*
* :return: base URI
* :rtype: string
*/
protected function _getBaseUri()
{
return 'https://lookups.twilio.com';
}
}

View File

@ -0,0 +1,110 @@
<?php
class Services_Twilio_AutoPagingIterator
implements Iterator
{
protected $generator;
protected $args;
protected $items;
private $_args;
public function __construct($generator, $page, $size, $filters) {
$this->generator = $generator;
$this->page = $page;
$this->size = $size;
$this->filters = $filters;
$this->next_page_uri = null;
$this->items = array();
// Save a backup for rewind()
$this->_args = array(
'page' => $page,
'size' => $size,
'filters' => $filters,
);
}
public function current()
{
return current($this->items);
}
public function key()
{
return key($this->items);
}
/*
* Return the next item in the list, making another HTTP call to the next
* page of resources if necessary.
*/
public function next()
{
try {
$this->loadIfNecessary();
return next($this->items);
}
catch (Services_Twilio_RestException $e) {
// 20006 is an out of range paging error, everything else is valid
if ($e->getCode() != 20006) {
throw $e;
}
}
}
/*
* Restore everything to the way it was before we began paging. This gets
* called at the beginning of any foreach() loop
*/
public function rewind()
{
foreach ($this->_args as $arg => $val) {
$this->$arg = $val;
}
$this->items = array();
$this->next_page_uri = null;
}
public function count()
{
throw new BadMethodCallException('Not allowed');
}
public function valid()
{
try {
$this->loadIfNecessary();
return key($this->items) !== null;
}
catch (Services_Twilio_RestException $e) {
// 20006 is an out of range paging error, everything else is valid
if ($e->getCode() != 20006) {
throw $e;
}
}
return false;
}
/*
* Fill $this->items with a new page from the API, if necessary.
*/
protected function loadIfNecessary()
{
if (// Empty because it's the first time or last page was empty
empty($this->items)
// null key when the items list is iterated over completely
|| key($this->items) === null
) {
$page = call_user_func_array($this->generator, array(
$this->page,
$this->size,
$this->filters,
$this->next_page_uri,
));
$this->next_page_uri = $page->next_page_uri;
$this->items = $page->getItems();
$this->page = $this->page + 1;
}
}
}

View File

@ -0,0 +1,185 @@
<?php
include_once 'JWT.php';
/**
* Twilio Capability Token generator
*
* @category Services
* @package Services_Twilio
* @author Jeff Lindsay <jeff.lindsay@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class Services_Twilio_Capability
{
public $accountSid;
public $authToken;
public $scopes;
/**
* Create a new TwilioCapability with zero permissions. Next steps are to
* grant access to resources by configuring this token through the
* functions allowXXXX.
*
* @param $accountSid the account sid to which this token is granted access
* @param $authToken the secret key used to sign the token. Note, this auth
* token is not visible to the user of the token.
*/
public function __construct($accountSid, $authToken)
{
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->scopes = array();
$this->clientName = false;
}
/**
* If the user of this token should be allowed to accept incoming
* connections then configure the TwilioCapability through this method and
* specify the client name.
*
* @param $clientName
*/
public function allowClientIncoming($clientName)
{
// clientName must be a non-zero length alphanumeric string
if (preg_match('/\W/', $clientName)) {
throw new InvalidArgumentException(
'Only alphanumeric characters allowed in client name.');
}
if (strlen($clientName) == 0) {
throw new InvalidArgumentException(
'Client name must not be a zero length string.');
}
$this->clientName = $clientName;
$this->allow('client', 'incoming',
array('clientName' => $clientName));
}
/**
* Allow the user of this token to make outgoing connections.
*
* @param $appSid the application to which this token grants access
* @param $appParams signed parameters that the user of this token cannot
* overwrite.
*/
public function allowClientOutgoing($appSid, array $appParams=array())
{
$this->allow('client', 'outgoing', array(
'appSid' => $appSid,
'appParams' => http_build_query($appParams, '', '&')));
}
/**
* Allow the user of this token to access their event stream.
*
* @param $filters key/value filters to apply to the event stream
*/
public function allowEventStream(array $filters=array())
{
$this->allow('stream', 'subscribe', array(
'path' => '/2010-04-01/Events',
'params' => http_build_query($filters, '', '&'),
));
}
/**
* Generates a new token based on the credentials and permissions that
* previously has been granted to this token.
*
* @param $ttl the expiration time of the token (in seconds). Default
* value is 3600 (1hr)
* @return the newly generated token that is valid for $ttl seconds
*/
public function generateToken($ttl = 3600)
{
$payload = array(
'scope' => array(),
'iss' => $this->accountSid,
'exp' => time() + $ttl,
);
$scopeStrings = array();
foreach ($this->scopes as $scope) {
if ($scope->privilege == "outgoing" && $this->clientName)
$scope->params["clientName"] = $this->clientName;
$scopeStrings[] = $scope->toString();
}
$payload['scope'] = implode(' ', $scopeStrings);
return JWT::encode($payload, $this->authToken, 'HS256');
}
protected function allow($service, $privilege, $params) {
$this->scopes[] = new ScopeURI($service, $privilege, $params);
}
}
/**
* Scope URI implementation
*
* Simple way to represent configurable privileges in an OAuth
* friendly way. For our case, they look like this:
*
* scope:<service>:<privilege>?<params>
*
* For example:
* scope:client:incoming?name=jonas
*
* @author Jeff Lindsay <jeff.lindsay@twilio.com>
*/
class ScopeURI
{
public $service;
public $privilege;
public $params;
public function __construct($service, $privilege, $params = array())
{
$this->service = $service;
$this->privilege = $privilege;
$this->params = $params;
}
public function toString()
{
$uri = "scope:{$this->service}:{$this->privilege}";
if (count($this->params)) {
$uri .= "?".http_build_query($this->params, '', '&');
}
return $uri;
}
/**
* Parse a scope URI into a ScopeURI object
*
* @param string $uri The scope URI
* @return ScopeURI The parsed scope uri
*/
public static function parse($uri)
{
if (strpos($uri, 'scope:') !== 0) {
throw new UnexpectedValueException(
'Not a scope URI according to scheme');
}
$parts = explode('?', $uri, 1);
$params = null;
if (count($parts) > 1) {
parse_str($parts[1], $params);
}
$parts = explode(':', $parts[0], 2);
if (count($parts) != 3) {
throw new UnexpectedValueException(
'Not enough parts for scope URI');
}
list($scheme, $service, $privilege) = $parts;
return new ScopeURI($service, $privilege, $params);
}
}

View File

@ -0,0 +1,133 @@
<?php
include_once 'JWT.php';
/**
* Twilio API Capability Token generator
*
* @category Services
* @package Services_Twilio
* @author Justin Witz <justin.witz@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class Services_Twilio_API_Capability
{
private $accountSid;
private $authToken;
private $version;
private $friendlyName;
private $policies;
public function __construct($accountSid, $authToken, $version, $friendlyName)
{
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->version = $version;
$this->friendlyName = $friendlyName;
$this->policies = array();
}
public function addPolicy($policy) {
array_push($this->policies, $policy);
}
public function generatePolicy($url, $method, $queryFilter = array(), $postFilter = array(), $allow = true)
{
$policy = new Policy($url, $method, $queryFilter, $postFilter, $allow);
return $policy;
}
public function generateAndAddPolicy($url, $method, $queryFilter = array(), $postFilter = array(), $allow = true) {
$policy = $this->generatePolicy($url, $method, $queryFilter, $postFilter, $allow);
$this->addPolicy($policy);
}
/**
* Generates a new token based on the credentials and permissions that
* previously has been granted to this token.
*
* @param $ttl the expiration time of the token (in seconds). Default
* value is 3600 (1hr)
* @param $extraAttributes extra attributes to be tied to the jwt.
* @return the newly generated token that is valid for $ttl seconds
*/
public function generateToken($ttl = 3600, $extraAttributes = null)
{
$payload = array(
'version' => $this->version,
'friendly_name' => $this->friendlyName,
'policies' => array(),
'iss' => $this->accountSid,
'exp' => time() + $ttl
);
if(isset($extraAttributes)) {
foreach ($extraAttributes as $key => $value) {
$payload[$key] = $value;
}
}
$policyStrings = array();
foreach ($this->policies as $policy) {
$policyStrings[] = $policy->toArray();
}
$payload['policies'] = $policyStrings;
return JWT::encode($payload, $this->authToken, 'HS256');
}
}
/**
* Twilio API Policy constructor
*
* @category Services
* @package Services_Twilio
* @author Justin Witz <justin.witz@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class Policy
{
private $url;
private $method;
private $queryFilter;
private $postFilter;
private $allow;
public function __construct($url, $method, $queryFilter = array(), $postFilter = array(), $allow = true)
{
$this->url = $url;
$this->method = $method;
$this->queryFilter = $queryFilter;
$this->postFilter = $postFilter;
$this->allow = $allow;
}
public function addQueryFilter($queryFilter)
{
array_push($this->queryFilter, $queryFilter);
}
public function addPostFilter($postFilter)
{
array_push($this->postFilter, $postFilter);
}
public function toArray() {
$policy_array = array('url' => $this->url, 'method' => $this->method, 'allow' => $this->allow);
if (!is_null($this->queryFilter)) {
if (count($this->queryFilter) > 0 ) {
$policy_array['query_filter'] = $this->queryFilter;
} else {
$policy_array['query_filter'] = new stdClass();
}
}
if (!is_null($this->postFilter)) {
if (count($this->postFilter) > 0 ) {
$policy_array['post_filter'] = $this->postFilter;
} else {
$policy_array['post_filter'] = new stdClass();
}
}
return $policy_array;
}
}

View File

@ -0,0 +1,92 @@
<?php
include_once 'CapabilityAPI.php';
/**
* Twilio TaskRouter Capability assigner
*
* @category Services
* @package Services_Twilio
* @author Justin Witz <justin.witz@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class Services_Twilio_TaskRouter_Worker_Capability
{
private $accountSid;
private $authToken;
private $workspaceSid;
private $workerSid;
private $apiCapability;
private $baseUrl = 'https://taskrouter.twilio.com/v1';
private $baseWsUrl = 'https://event-bridge.twilio.com/v1/wschannels';
private $workerUrl;
private $reservationsUrl;
private $activityUrl;
private $required = array("required" => true);
private $optional = array("required" => false);
public function __construct($accountSid, $authToken, $workspaceSid, $workerSid, $overrideBaseUrl = null, $overrideBaseWSUrl = null)
{
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->workspaceSid = $workspaceSid;
$this->workerSid = $workerSid;
$this->apiCapability = new Services_Twilio_API_Capability($accountSid, $authToken, 'v1', $workerSid);
if(isset($overrideBaseUrl)) {
$this->baseUrl = $overrideBaseUrl;
}
if(isset($overrideBaseWSUrl)) {
$this->baseWsUrl = $overrideBaseWSUrl;
}
$this->baseUrl = $this->baseUrl.'/Workspaces/'.$workspaceSid;
$this->workerUrl = $this->baseUrl.'/Workers/'.$workerSid;
$this->reservationsUrl = $this->baseUrl.'/Tasks/**';
$this->activityUrl = $this->baseUrl.'/Activities';
//add permissions to GET and POST to the worker URI
$this->apiCapability->generateAndAddPolicy($this->baseWsUrl."/".$this->accountSid."/".$this->workerSid, "GET", null, null);
$this->apiCapability->generateAndAddPolicy($this->baseWsUrl."/".$this->accountSid."/".$this->workerSid, "POST", null, null);
$this->apiCapability->generateAndAddPolicy($this->activityUrl, "GET", null, null);
}
public function allowWorkerActivityUpdates() {
$method = 'POST';
$queryFilter = array();
$postFilter = array("ActivitySid" => $this->required);
$this->apiCapability->generateAndAddPolicy($this->workerUrl, $method, $queryFilter, $postFilter);
}
public function allowWorkerFetchAttributes() {
$method = 'GET';
$queryFilter = array();
$postFilter = array();
$this->apiCapability->generateAndAddPolicy($this->workerUrl, $method, $queryFilter, $postFilter);
}
public function allowTaskReservationUpdates() {
$method = 'POST';
$queryFilter = array();
$postFilter = array("ReservationStatus" => $this->required);
$this->apiCapability->generateAndAddPolicy($this->reservationsUrl, $method, $queryFilter, $postFilter);
}
public function allowActivityListFetch(){
$method = 'GET';
$queryFilter = array();
$postFilter = array();
$this->apiCapability->generateAndAddPolicy($this->activityUrl, $method, $queryFilter, $postFilter);
}
public function generateToken($ttl = 3600) {
$taskRouterAttributes = array(
'account_sid' => $this->accountSid,
'channel' => $this->workerSid,
'workspace_sid' => $this->workspaceSid,
'worker_sid' => $this->workerSid,
);
return $this->apiCapability->generateToken($ttl, $taskRouterAttributes);
}
}

View File

@ -0,0 +1,3 @@
<?php
class Services_Twilio_HttpException extends ErrorException {}

View File

@ -0,0 +1,99 @@
<?php
/**
* HTTP Stream version of the TinyHttp Client used to connect to Twilio
* services.
*/
class Services_Twilio_HttpStreamException extends ErrorException {}
class Services_Twilio_HttpStream {
private $auth_header = null;
private $uri = null;
private $debug = false;
private static $default_options = array(
"http" => array(
"headers" => "",
"timeout" => 60,
"follow_location" => true,
"ignore_errors" => true,
),
"ssl" => array(),
);
private $options = array();
public function __construct($uri = '', $kwargs = array()) {
$this->uri = $uri;
if (isset($kwargs['debug'])) {
$this->debug = true;
}
if (isset($kwargs['http_options'])) {
$this->options = $kwargs['http_options'] + self::$default_options;
} else {
$this->options = self::$default_options;
}
}
public function __call($name, $args) {
list($res, $req_headers, $req_body) = $args + array(0, array(), '');
if (strpos($res, 'http') === 0) {
$url = $res;
} else {
$url = $this->uri . $res;
}
$request_options = $this->options;
if (isset($req_body) && strlen($req_body) > 0) {
$request_options['http']['content'] = $req_body;
}
foreach($req_headers as $key => $value) {
$request_options['http']['header'] .= sprintf("%s: %s\r\n", $key, $value);
}
if (isset($this->auth_header)) {
$request_options['http']['header'] .= $this->auth_header;
}
$request_options['http']['method'] = strtoupper($name);
$request_options['http']['ignore_errors'] = true;
if ($this->debug) {
error_log(var_export($request_options, true));
}
$ctx = stream_context_create($request_options);
$result = file_get_contents($url, false, $ctx);
if (false === $result) {
throw new Services_Twilio_HttpStreamException(
"Unable to connect to service");
}
$status_header = array_shift($http_response_header);
if (1 !== preg_match('#HTTP/\d+\.\d+ (\d+)#', $status_header, $matches)) {
throw new Services_Twilio_HttpStreamException(
"Unable to detect the status code in the HTTP result.");
}
$status_code = intval($matches[1]);
$response_headers = array();
foreach($http_response_header as $header) {
list($key, $val) = explode(":", $header);
$response_headers[trim($key)] = trim($val);
}
return array($status_code, $response_headers, $result);
}
public function authenticate($user, $pass) {
if (isset($user) && isset($pass)) {
$this->auth_header = sprintf("Authorization: Basic %s",
base64_encode(sprintf("%s:%s", $user, $pass)));
} else {
$this->auth_header = null;
}
}
}

View File

@ -0,0 +1,84 @@
<?php
/**
* @category Services
* @package Services_Twilio
* @author Neuman Vong <neuman@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
* @link http://pear.php.net/package/Services_Twilio
*/
/**
* Abstraction of an instance resource from the Twilio API.
*/
abstract class Services_Twilio_InstanceResource extends Services_Twilio_Resource {
/**
* Make a request to the API to update an instance resource
*
* :param mixed $params: An array of updates, or a property name
* :param mixed $value: A value with which to update the resource
*
* :rtype: null
* :throws: a :php:class:`RestException <Services_Twilio_RestException>` if
* the update fails.
*/
public function update($params, $value = null)
{
if (!is_array($params)) {
$params = array($params => $value);
}
$decamelizedParams = $this->client->createData($this->uri, $params);
$this->updateAttributes($decamelizedParams);
}
/*
* Add all properties from an associative array (the JSON response body) as
* properties on this instance resource, except the URI
*
* :param stdClass $params: An object containing all of the parameters of
* this instance
* :return: Nothing, this is purely side effecting
* :rtype: null
*/
public function updateAttributes($params) {
unset($params->uri);
foreach ($params as $name => $value) {
$this->$name = $value;
}
}
/**
* Get the value of a property on this resource.
*
* Instead of defining all of the properties of an object directly, we rely
* on the API to tell us which properties an object has. This method will
* query the API to retrieve a property for an object, if it is not already
* set on the object.
*
* If the call is to a subresource, eg ``$client->account->messages``, no
* request is made.
*
* To help with lazy HTTP requests, we don't actually retrieve an object
* from the API unless you really need it. Hence, this function may make API
* requests even if the property you're requesting isn't available on the
* resource.
*
* :param string $key: The property name
*
* :return mixed: Could be anything.
* :throws: a :php:class:`RestException <Services_Twilio_RestException>` if
* the update fails.
*/
public function __get($key)
{
if ($subresource = $this->getSubresources($key)) {
return $subresource;
}
if (!isset($this->$key)) {
$params = $this->client->retrieveData($this->uri);
$this->updateAttributes($params);
}
return $this->$key;
}
}

View File

@ -0,0 +1,162 @@
<?php
/**
* JSON Web Token implementation
*
* Minimum implementation used by Realtime auth, based on this spec:
* http://self-issued.info/docs/draft-jones-json-web-token-01.html.
*
* @author Neuman Vong <neuman@twilio.com>
*/
class JWT
{
/**
* @param string $jwt The JWT
* @param string|null $key The secret key
* @param bool $verify Don't skip verification process
*
* @return object The JWT's payload as a PHP object
*/
public static function decode($jwt, $key = null, $verify = true)
{
$tks = explode('.', $jwt);
if (count($tks) != 3) {
throw new UnexpectedValueException('Wrong number of segments');
}
list($headb64, $payloadb64, $cryptob64) = $tks;
if (null === ($header = JWT::jsonDecode(JWT::urlsafeB64Decode($headb64)))
) {
throw new UnexpectedValueException('Invalid segment encoding');
}
if (null === $payload = JWT::jsonDecode(JWT::urlsafeB64Decode($payloadb64))
) {
throw new UnexpectedValueException('Invalid segment encoding');
}
$sig = JWT::urlsafeB64Decode($cryptob64);
if ($verify) {
if (empty($header->alg)) {
throw new DomainException('Empty algorithm');
}
if ($sig != JWT::sign("$headb64.$payloadb64", $key, $header->alg)) {
throw new UnexpectedValueException('Signature verification failed');
}
}
return $payload;
}
/**
* @param object|array $payload PHP object or array
* @param string $key The secret key
* @param string $algo The signing algorithm
*
* @return string A JWT
*/
public static function encode($payload, $key, $algo = 'HS256')
{
$header = array('typ' => 'JWT', 'alg' => $algo);
$segments = array();
$segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header));
$segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($payload));
$signing_input = implode('.', $segments);
$signature = JWT::sign($signing_input, $key, $algo);
$segments[] = JWT::urlsafeB64Encode($signature);
return implode('.', $segments);
}
/**
* @param string $msg The message to sign
* @param string $key The secret key
* @param string $method The signing algorithm
*
* @return string An encrypted message
*/
public static function sign($msg, $key, $method = 'HS256')
{
$methods = array(
'HS256' => 'sha256',
'HS384' => 'sha384',
'HS512' => 'sha512',
);
if (empty($methods[$method])) {
throw new DomainException('Algorithm not supported');
}
return hash_hmac($methods[$method], $msg, $key, true);
}
/**
* @param string $input JSON string
*
* @return object Object representation of JSON string
*/
public static function jsonDecode($input)
{
$obj = json_decode($input);
if (function_exists('json_last_error') && $errno = json_last_error()) {
JWT::handleJsonError($errno);
}
else if ($obj === null && $input !== 'null') {
throw new DomainException('Null result with non-null input');
}
return $obj;
}
/**
* @param object|array $input A PHP object or array
*
* @return string JSON representation of the PHP object or array
*/
public static function jsonEncode($input)
{
$json = json_encode($input);
if (function_exists('json_last_error') && $errno = json_last_error()) {
JWT::handleJsonError($errno);
}
else if ($json === 'null' && $input !== null) {
throw new DomainException('Null result with non-null input');
}
return $json;
}
/**
* @param string $input A base64 encoded string
*
* @return string A decoded string
*/
public static function urlsafeB64Decode($input)
{
$padlen = 4 - strlen($input) % 4;
$input .= str_repeat('=', $padlen);
return base64_decode(strtr($input, '-_', '+/'));
}
/**
* @param string $input Anything really
*
* @return string The base64 encode of what you passed in
*/
public static function urlsafeB64Encode($input)
{
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}
/**
* @param int $errno An error number from json_last_error()
*
* @return void
*/
private static function handleJsonError($errno)
{
$messages = array(
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
);
throw new DomainException(isset($messages[$errno])
? $messages[$errno]
: 'Unknown JSON error: ' . $errno
);
}
}

View File

@ -0,0 +1,203 @@
<?php
/**
* @author Neuman Vong neuman@twilio.com
* @license http://creativecommons.org/licenses/MIT/ MIT
* @link http://pear.php.net/package/Services_Twilio
*/
/**
* Abstraction of a list resource from the Twilio API.
*
* The list resource implements the `IteratorAggregate
* <http://php.net/manual/en/class.iteratoraggregate.php>`_ and the `Countable
* <http://php.net/manual/en/class.countable.php>`_ interfaces.
*
*/
abstract class Services_Twilio_ListResource extends Services_Twilio_Resource
implements IteratorAggregate, Countable
{
public function __construct($client, $uri) {
$name = $this->getResourceName(true);
/*
* By default trim the 's' from the end of the list name to get the
* instance name (ex Accounts -> Account). This behavior can be
* overridden by child classes if the rule doesn't work.
*/
if (!isset($this->instance_name)) {
$this->instance_name = "Services_Twilio_Rest_" . rtrim($name, 's');
}
parent::__construct($client, $uri);
}
/**
* Gets a resource from this list.
*
* :param string $sid: The resource SID
* :return: The resource
* :rtype: :php:class:`InstanceResource <Services_Twilio_InstanceResource>`
*/
public function get($sid) {
$instance = new $this->instance_name(
$this->client, $this->uri . "/$sid"
);
// XXX check if this is actually a sid in all cases.
$instance->sid = $sid;
return $instance;
}
/**
* Construct an :php:class:`InstanceResource
* <Services_Twilio_InstanceResource>` with the specified params.
*
* :param array $params: usually a JSON HTTP response from the API
* :return: An instance with properties
* initialized to the values in the params array.
* :rtype: :php:class:`InstanceResource <Services_Twilio_InstanceResource>`
*/
public function getObjectFromJson($params, $idParam = "sid")
{
if (isset($params->{$idParam})) {
$uri = $this->uri . "/" . $params->{$idParam};
} else {
$uri = $this->uri;
}
return new $this->instance_name($this->client, $uri, $params);
}
/**
* Deletes a resource from this list.
*
* :param string $sid: The resource SID
* :rtype: null
*/
public function delete($sid, $params = array())
{
$this->client->deleteData($this->uri . '/' . $sid, $params);
}
/**
* Create a resource on the list and then return its representation as an
* InstanceResource.
*
* :param array $params: The parameters with which to create the resource
*
* :return: The created resource
* :rtype: :php:class:`InstanceResource <Services_Twilio_InstanceResource>`
*/
protected function _create($params)
{
$params = $this->client->createData($this->uri, $params);
/* Some methods like verified caller ID don't return sids. */
if (isset($params->sid)) {
$resource_uri = $this->uri . '/' . $params->sid;
} else {
$resource_uri = $this->uri;
}
return new $this->instance_name($this->client, $resource_uri, $params);
}
/**
* Returns a page of :php:class:`InstanceResources
* <Services_Twilio_InstanceResource>` from this list.
*
* :param int $page: The start page
* :param int $size: Number of items per page
* :param array $filters: Optional filters
* :param string $deep_paging_uri: if provided, the $page and $size
* parameters will be ignored and this URI will be requested directly.
*
* :return: A page of resources
* :rtype: :php:class:`Services_Twilio_Page`
*/
public function getPage(
$page = 0, $size = 50, $filters = array(), $deep_paging_uri = null
) {
$list_name = $this->getResourceName();
if ($deep_paging_uri !== null) {
$page = $this->client->retrieveData($deep_paging_uri, array(), true);
} else {
$page = $this->client->retrieveData($this->uri, array(
'Page' => $page,
'PageSize' => $size,
) + $filters);
}
/* create a new PHP object for each json obj in the api response. */
$page->$list_name = array_map(
array($this, 'getObjectFromJson'),
$page->$list_name
);
if (isset($page->next_page_uri)) {
$next_page_uri = $page->next_page_uri;
} else {
$next_page_uri = null;
}
return new Services_Twilio_Page($page, $list_name, $next_page_uri);
}
/**
* Get the total number of instances for this list.
*
* This will make one HTTP request to retrieve the total, every time this
* method is called.
*
* If the total is not set, or an Exception was thrown, returns 0
*
* :return: The total number of instance members
* :rtype: integer
*/
public function count() {
try {
$page = $this->getPage(0, 1);
return $page ? (int)$page->total : 0;
} catch (Exception $e) {
return 0;
}
}
/**
* Returns an iterable list of
* :php:class:`instance resources <Services_Twilio_InstanceResource>`.
*
* :param int $page: The start page
* :param int $size: Number of items per page
* :param array $filters: Optional filters.
* The filter array can accept full datetimes when StartTime or DateCreated
* are used. Inequalities should be within the key portion of the array and
* multiple filter parameters can be combined for more specific searches.
*
* .. code-block:: php
*
* array('DateCreated>' => '2011-07-05 08:00:00', 'DateCreated<' => '2011-08-01')
*
* .. code-block:: php
*
* array('StartTime<' => '2011-07-05 08:00:00')
*
* :return: An iterator
* :rtype: :php:class:`Services_Twilio_AutoPagingIterator`
*/
public function getIterator(
$page = 0, $size = 50, $filters = array()
) {
return new Services_Twilio_AutoPagingIterator(
array($this, 'getPageGenerator'), $page, $size, $filters
);
}
/**
* Retrieve a new page of API results, and update iterator parameters. This
* function is called by the paging iterator to retrieve a new page and
* shouldn't be called directly.
*/
public function getPageGenerator(
$page, $size, $filters = array(), $deep_paging_uri = null
) {
return $this->getPage($page, $size, $filters, $deep_paging_uri);
}
}

View File

@ -0,0 +1,15 @@
<?php
abstract class Services_Twilio_LookupsInstanceResource extends Services_Twilio_NextGenInstanceResource {
protected function setupSubresources() {
foreach (func_get_args() as $name) {
$constantized = ucfirst(self::camelize($name));
$type = "Services_Twilio_Rest_Lookups_" . $constantized;
$this->subresources[$name] = new $type(
$this->client, $this->uri . "/$constantized"
);
}
}
}

View File

@ -0,0 +1,39 @@
<?php
abstract class Services_Twilio_LookupsListResource extends Services_Twilio_NextGenListResource {
public function __construct($client, $uri) {
$name = $this->getResourceName(true);
/*
* By default trim the 's' from the end of the list name to get the
* instance name (ex Accounts -> Account). This behavior can be
* overridden by child classes if the rule doesn't work.
*/
if (!isset($this->instance_name)) {
$this->instance_name = "Services_Twilio_Rest_Lookups_" . rtrim($name, 's');
}
parent::__construct($client, $uri);
}
/**
* Gets a resource from this list. Overridden to add
* filter parameters.
*
* :param string $number: The phone number
* :return: The resource
* :rtype: :php:class:`InstanceResource <Services_Twilio_InstanceResource>`
*/
public function get($number, $filters = array()) {
$full_path = $this->uri . "/$number";
if (!empty($filters)) {
$full_path .= '?' . http_build_query($filters, '', '&');
}
$instance = new $this->instance_name(
$this->client, $full_path
);
$instance->number = $number;
return $instance;
}
}

View File

@ -0,0 +1,23 @@
<?php
abstract class Services_Twilio_NextGenInstanceResource extends Services_Twilio_InstanceResource {
/**
* Make a request to the API to update an instance resource
*
* :param mixed $params: An array of updates, or a property name
* :param mixed $value: A value with which to update the resource
*
* :rtype: null
* :throws: a :php:class:`RestException <Services_Twilio_RestException>` if
* the update fails.
*/
public function update($params, $value = null)
{
if (!is_array($params)) {
$params = array($params => $value);
}
$decamelizedParams = $this->client->createData($this->uri, $params, true);
$this->updateAttributes($decamelizedParams);
}
}

View File

@ -0,0 +1,60 @@
<?php
class Services_Twilio_NextGenListResource extends Services_Twilio_ListResource {
public function getPage($page = 0, $size = 50, $filters = array(), $deep_paging_uri = null) {
if ($deep_paging_uri !== null) {
$page = $this->client->retrieveData($deep_paging_uri, array(), true);
} else if ($page == 0) {
$page = $this->client->retrieveData($this->uri, array('Page' => $page, 'PageSize' => $size) + $filters);
} else {
return $this->emptyPage();
}
$list_name = $page->meta->key;
if (!isset($list_name) || $list_name === '') {
throw new Services_Twilio_HttpException("Couldn't find list key in response");
}
$page->$list_name = array_map(
array($this, 'getObjectFromJson'),
$page->$list_name
);
$page->next_page_uri = $page->meta->next_page_url;
return new Services_Twilio_Page($page, $list_name, $page->meta->next_page_url);
}
private function emptyPage() {
$page = new stdClass();
$page->empty = array();
return new Services_Twilio_Page($page, 'empty');
}
/**
* Create a resource on the list and then return its representation as an
* InstanceResource.
*
* :param array $params: The parameters with which to create the resource
*
* :return: The created resource
* :rtype: :php:class:`InstanceResource <Services_Twilio_InstanceResource>`
*/
protected function _create($params)
{
$params = $this->client->createData($this->uri, $params, true);
/* Some methods like verified caller ID don't return sids. */
if (isset($params->sid)) {
$resource_uri = $this->uri . '/' . $params->sid;
} else {
$resource_uri = $this->uri;
}
return new $this->instance_name($this->client, $resource_uri, $params);
}
public function count() {
throw new BadMethodCallException("Counting is not supported by this resource");
}
}

View File

@ -0,0 +1,35 @@
<?php
class Services_Twilio_NumberType extends Services_Twilio_ListResource
{
public function getResourceName($camelized = false) {
$this->instance_name = 'Services_Twilio_Rest_IncomingPhoneNumber';
return $camelized ? 'IncomingPhoneNumbers' : 'incoming_phone_numbers';
}
/**
* Purchase a new phone number.
*
* Example usage:
*
* .. code-block:: php
*
* $marlosBurner = '+14105551234';
* $client->account->incoming_phone_numbers->local->purchase($marlosBurner);
*
* :param string $phone_number: The phone number to purchase
* :param array $params: An optional array of parameters to pass along with
* the request (to configure the phone number)
*/
public function purchase($phone_number, array $params = array()) {
$postParams = array(
'PhoneNumber' => $phone_number
);
return $this->create($postParams + $params);
}
public function create(array $params = array()) {
return parent::_create($params);
}
}

View File

@ -0,0 +1,68 @@
<?php
/**
* A representation of a page of resources.
*
* @category Services
* @package Services_Twilio
* @author Neuman Vong <neuman@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
* @link http://pear.php.net/package/Services_Twilio
*/
class Services_Twilio_Page
implements IteratorAggregate
{
/**
* The item list.
*
* @var array $items
*/
protected $items;
/**
* Constructs a page.
*
* @param object $page The page object
* @param string $name The key of the item list
*/
public function __construct($page, $name, $next_page_uri = null)
{
$this->page = $page;
$this->items = $page->{$name};
$this->next_page_uri = $next_page_uri;
}
/**
* The item list of the page.
*
* @return array A list of instance resources
*/
public function getItems()
{
return $this->items;
}
/**
* Magic method to allow retrieving the properties of the wrapped page.
*
* @param string $prop The property name
*
* @return mixed Could be anything
*/
public function __get($prop)
{
return $this->page->$prop;
}
/**
* Implementation of IteratorAggregate::getIterator().
*
* @return Traversable
*/
public function getIterator()
{
return $this->getItems();
}
}

View File

@ -0,0 +1,41 @@
<?php
/**
* Helper class to wrap an object with a modified interface created by
* a partial application of its existing methods.
*
* @category Services
* @package Services_Twilio
* @author Neuman Vong <neuman@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
* @link http://pear.php.net/package/Services_Twilio
*/
class Services_Twilio_PartialApplicationHelper
{
private $callbacks;
public function __construct()
{
$this->callbacks = array();
}
public function set($method, $callback, array $args)
{
if (!is_callable($callback)) {
return FALSE;
}
$this->callbacks[$method] = array($callback, $args);
}
public function __call($method, $args)
{
if (!isset($this->callbacks[$method])) {
throw new Exception("Method not found: $method");
}
list($callback, $cb_args) = $this->callbacks[$method];
return call_user_func_array(
$callback,
array_merge($cb_args, $args)
);
}
}

View File

@ -0,0 +1,36 @@
<?php
class Services_Twilio_RequestValidator
{
protected $AuthToken;
function __construct($token)
{
$this->AuthToken = $token;
}
public function computeSignature($url, $data = array())
{
// sort the array by keys
ksort($data);
// append them to the data string in order
// with no delimiters
foreach($data as $key => $value)
$url .= "$key$value";
// This function calculates the HMAC hash of the data with the key
// passed in
// Note: hash_hmac requires PHP 5 >= 5.1.2 or PECL hash:1.1-1.5
// Or http://pear.php.net/package/Crypt_HMAC/
return base64_encode(hash_hmac("sha1", $url, $this->AuthToken, true));
}
public function validate($expectedSignature, $url, $data = array())
{
return $this->computeSignature($url, $data)
== $expectedSignature;
}
}

View File

@ -0,0 +1,134 @@
<?php
/**
* Abstraction of a Twilio resource.
*
* @category Services
* @package Services_Twilio
* @author Neuman Vong <neuman@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
* @link http://pear.php.net/package/Services_Twilio
*/
abstract class Services_Twilio_Resource {
protected $subresources;
public function __construct($client, $uri, $params = array())
{
$this->subresources = array();
$this->client = $client;
foreach ($params as $name => $param) {
$this->$name = $param;
}
$this->uri = $uri;
$this->init($client, $uri);
}
protected function init($client, $uri)
{
// Left empty for derived classes to implement
}
public function getSubresources($name = null) {
if (isset($name)) {
return isset($this->subresources[$name])
? $this->subresources[$name]
: null;
}
return $this->subresources;
}
protected function setupSubresources()
{
foreach (func_get_args() as $name) {
$constantized = ucfirst(self::camelize($name));
$type = "Services_Twilio_Rest_" . $constantized;
$this->subresources[$name] = new $type(
$this->client, $this->uri . "/$constantized"
);
}
}
/*
* Get the resource name from the classname
*
* Ex: Services_Twilio_Rest_Accounts -> Accounts
*
* @param boolean $camelized Whether to return camel case or not
*/
public function getResourceName($camelized = false)
{
$name = get_class($this);
$parts = explode('_', $name);
$basename = end($parts);
if ($camelized) {
return $basename;
} else {
return self::decamelize($basename);
}
}
public static function decamelize($word)
{
$callback = create_function('$matches',
'return strtolower(strlen("$matches[1]") ? "$matches[1]_$matches[2]" : "$matches[2]");');
return preg_replace_callback(
'/(^|[a-z])([A-Z])/',
$callback,
$word
);
}
/**
* Return camelized version of a word
* Examples: sms_messages => SMSMessages, calls => Calls,
* incoming_phone_numbers => IncomingPhoneNumbers
*
* @param string $word The word to camelize
* @return string
*/
public static function camelize($word) {
$callback = create_function('$matches', 'return strtoupper("$matches[2]");');
return preg_replace_callback('/(^|_)([a-z])/',
$callback,
$word);
}
/**
* Get the value of a property on this resource.
*
* @param string $key The property name
* @return mixed Could be anything.
*/
public function __get($key) {
if ($subresource = $this->getSubresources($key)) {
return $subresource;
}
return $this->$key;
}
/**
* Print a JSON representation of this object. Strips the HTTP client
* before returning.
*
* Note, this should mainly be used for debugging, and is not guaranteed
* to correspond 1:1 with the JSON API output.
*
* Note that echoing an object before an HTTP request has been made to
* "fill in" its properties may return an empty object
*/
public function __toString() {
$out = array();
foreach ($this as $key => $value) {
if ($key !== 'client' && $key !== 'subresources') {
$out[$key] = $value;
}
}
return json_encode($out, true);
}
}

View File

@ -0,0 +1,35 @@
<?php
class Services_Twilio_Rest_Account extends Services_Twilio_InstanceResource {
protected function init($client, $uri) {
$this->setupSubresources(
'applications',
'available_phone_numbers',
'outgoing_caller_ids',
'calls',
'conferences',
'incoming_phone_numbers',
'media',
'messages',
'notifications',
'outgoing_callerids',
'recordings',
'sms_messages',
'short_codes',
'tokens',
'transcriptions',
'connect_apps',
'authorized_connect_apps',
'usage_records',
'usage_triggers',
'queues',
'sip',
'addresses'
);
$this->sandbox = new Services_Twilio_Rest_Sandbox(
$client, $uri . '/Sandbox'
);
}
}

View File

@ -0,0 +1,25 @@
<?php
/**
* For more information, see the `Account List Resource
* <http://www.twilio.com/docs/api/rest/account#list>`_ documentation.
*/
class Services_Twilio_Rest_Accounts extends Services_Twilio_ListResource {
/**
* Create a new subaccount.
*
* :param array $params: An array of parameters describing the new
* subaccount. The ``$params`` array can contain the following keys:
*
* *FriendlyName*
* A description of this account, up to 64 characters long
*
* :returns: The new subaccount
* :rtype: :php:class:`Services_Twilio_Rest_Account`
*
*/
public function create($params = array()) {
return parent::_create($params);
}
}

View File

@ -0,0 +1,12 @@
<?php
class Services_Twilio_Rest_Address
extends Services_Twilio_InstanceResource
{
protected function init($client, $uri)
{
$this->setupSubresources(
'dependent_phone_numbers'
);
}
}

View File

@ -0,0 +1,6 @@
<?php
class Services_Twilio_Rest_Addresses
extends Services_Twilio_ListResource
{
}

View File

@ -0,0 +1,6 @@
<?php
class Services_Twilio_Rest_Application
extends Services_Twilio_InstanceResource
{
}

View File

@ -0,0 +1,12 @@
<?php
class Services_Twilio_Rest_Applications
extends Services_Twilio_ListResource
{
public function create($name, array $params = array())
{
return parent::_create(array(
'FriendlyName' => $name
) + $params);
}
}

View File

@ -0,0 +1,6 @@
<?php
class Services_Twilio_Rest_AuthorizedConnectApp
extends Services_Twilio_InstanceResource
{
}

View File

@ -0,0 +1,10 @@
<?php
class Services_Twilio_Rest_AuthorizedConnectApps
extends Services_Twilio_ListResource
{
public function create($name, array $params = array())
{
throw new BadMethodCallException('Not allowed');
}
}

View File

@ -0,0 +1,7 @@
<?php
class Services_Twilio_Rest_AvailablePhoneNumber
extends Services_Twilio_InstanceResource
{
}

View File

@ -0,0 +1,54 @@
<?php
class Services_Twilio_Rest_AvailablePhoneNumbers
extends Services_Twilio_ListResource
{
public function getLocal($country) {
$curried = new Services_Twilio_PartialApplicationHelper();
$curried->set(
'getList',
array($this, 'getList'),
array($country, 'Local')
);
return $curried;
}
public function getTollFree($country) {
$curried = new Services_Twilio_PartialApplicationHelper();
$curried->set(
'getList',
array($this, 'getList'),
array($country, 'TollFree')
);
return $curried;
}
public function getMobile($country)
{
$curried = new Services_Twilio_PartialApplicationHelper();
$curried->set(
'getList',
array($this, 'getList'),
array($country, 'Mobile')
);
return $curried;
}
/**
* Get a list of available phone numbers.
*
* @param string $country The 2-digit country code you'd like to search for
* numbers e.g. ('US', 'CA', 'GB')
* @param string $type The type of number ('Local', 'TollFree', or 'Mobile')
* @return object The object representation of the resource
*/
public function getList($country, $type, array $params = array())
{
return $this->client->retrieveData($this->uri . "/$country/$type", $params);
}
public function getResourceName($camelized = false) {
// You can't page through the list of available phone numbers.
$this->instance_name = 'Services_Twilio_Rest_AvailablePhoneNumber';
return $camelized ? 'Countries' : 'countries';
}
}

View File

@ -0,0 +1,106 @@
<?php
/**
* For more information, see the `Call Instance Resource <http://www.twilio.com/docs/api/rest/call#instance>`_ documentation.
*
* .. php:attr:: sid
*
* A 34 character string that uniquely identifies this resource.
*
* .. php:attr:: parent_call_sid
*
* A 34 character string that uniquely identifies the call that created this leg.
*
* .. php:attr:: date_created
*
* The date that this resource was created, given as GMT in RFC 2822 format.
*
* .. php:attr:: date_updated
*
* The date that this resource was last updated, given as GMT in RFC 2822 format.
*
* .. php:attr:: account_sid
*
* The unique id of the Account responsible for creating this call.
*
* .. php:attr:: to
*
* The phone number that received this call. e.g., +16175551212 (E.164 format)
*
* .. php:attr:: from
*
* The phone number that made this call. e.g., +16175551212 (E.164 format)
*
* .. php:attr:: phone_number_sid
*
* If the call was inbound, this is the Sid of the IncomingPhoneNumber that
* received the call. If the call was outbound, it is the Sid of the
* OutgoingCallerId from which the call was placed.
*
* .. php:attr:: status
*
* A string representing the status of the call. May be `QUEUED`, `RINGING`,
* `IN-PROGRESS`, `COMPLETED`, `FAILED`, `BUSY` or `NO_ANSWER`.
*
* .. php:attr:: start_time
*
* The start time of the call, given as GMT in RFC 2822 format. Empty if the call has not yet been dialed.
*
* .. php:attr:: end_time
*
* The end time of the call, given as GMT in RFC 2822 format. Empty if the call did not complete successfully.
*
* .. php:attr:: duration
*
* The length of the call in seconds. This value is empty for busy, failed, unanswered or ongoing calls.
*
* .. php:attr:: price
*
* The charge for this call in USD. Populated after the call is completed. May not be immediately available.
*
* .. php:attr:: direction
*
* A string describing the direction of the call. inbound for inbound
* calls, outbound-api for calls initiated via the REST API or
* outbound-dial for calls initiated by a <Dial> verb.
*
* .. php:attr:: answered_by
*
* If this call was initiated with answering machine detection, either human or machine. Empty otherwise.
*
* .. php:attr:: forwarded_from
*
* If this call was an incoming call forwarded from another number, the
* forwarding phone number (depends on carrier supporting forwarding).
* Empty otherwise.
*
* .. php:attr:: caller_name
*
* If this call was an incoming call from a phone number with Caller ID Lookup enabled, the caller's name. Empty otherwise.
*/
class Services_Twilio_Rest_Call extends Services_Twilio_InstanceResource {
/**
* Hang up the call
*/
public function hangup() {
$this->update('Status', 'completed');
}
/**
* Redirect the call to a new URL
*
* :param string $url: the new URL to retrieve call flow from.
*/
public function route($url) {
$this->update('Url', $url);
}
protected function init($client, $uri) {
$this->setupSubresources(
'notifications',
'recordings',
'feedback'
);
}
}

View File

@ -0,0 +1,77 @@
<?php
class Services_Twilio_Rest_Calls
extends Services_Twilio_ListResource
{
function init($client, $uri)
{
$this->setupSubresources(
'feedback_summary'
);
}
public static function isApplicationSid($value)
{
return strlen($value) == 34
&& !(strpos($value, "AP") === false);
}
public function create($from, $to, $url, array $params = array())
{
$params["To"] = $to;
$params["From"] = $from;
if (self::isApplicationSid($url)) {
$params["ApplicationSid"] = $url;
} else {
$params["Url"] = $url;
}
return parent::_create($params);
}
/**
* Create a feedback for a call.
*
* @param $callSid
* @param $qualityScore
* @param array $issue
* @return Services_Twilio_Rest_Feedback
*/
public function createFeedback($callSid, $qualityScore, array $issue = array())
{
$params["QualityScore"] = $qualityScore;
$params["Issue"] = $issue;
$feedbackUri = $this->uri . '/' . $callSid . '/Feedback';
$response = $this->client->createData($feedbackUri, $params);
return new Services_Twilio_Rest_Feedback($this->client, $feedbackUri, $response);
}
/**
* Delete a feedback for a call.
*
* @param $callSid
*/
public function deleteFeedback($callSid)
{
$feedbackUri = $this->uri . '/' . $callSid . '/Feedback';
$this->client->deleteData($feedbackUri);
}
/**
* Get a feedback for a call.
*
* @param $callSid
* @return Services_Twilio_Rest_Feedback
*/
public function getFeedback($callSid)
{
$feedbackUri = $this->uri . '/' . $callSid . '/Feedback';
$response = $this->client->retrieveData($feedbackUri);
return new Services_Twilio_Rest_Feedback($this->client, $feedbackUri, $response);
}
}

View File

@ -0,0 +1,12 @@
<?php
class Services_Twilio_Rest_Conference
extends Services_Twilio_InstanceResource
{
protected function init($client, $uri)
{
$this->setupSubresources(
'participants'
);
}
}

View File

@ -0,0 +1,6 @@
<?php
class Services_Twilio_Rest_Conferences
extends Services_Twilio_ListResource
{
}

View File

@ -0,0 +1,6 @@
<?php
class Services_Twilio_Rest_ConnectApp
extends Services_Twilio_InstanceResource
{
}

View File

@ -0,0 +1,10 @@
<?php
class Services_Twilio_Rest_ConnectApps
extends Services_Twilio_ListResource
{
public function create($name, array $params = array())
{
throw new BadMethodCallException('Not allowed');
}
}

View File

@ -0,0 +1,30 @@
<?php
/**
* A single Credential
*
* .. php:attr:: date_created
*
* The date the Credential was created
*
* .. php:attr:: date_updated
*
* The date the Credential was updated
*
* .. php:attr:: sid
*
* A 34 character string that identifies this object
*
* .. php:attr:: account_sid
*
* The account that created this credential
*
* .. php:attr:: username
*
* The username of this Credential object
*
* .. php:attr:: uri
*
* The uri of this Credential object
*/
class Services_Twilio_Rest_Credential extends Services_Twilio_InstanceResource { }

View File

@ -0,0 +1,42 @@
<?php
/**
* A single CredentialList
*
* .. php:attr:: date_created
*
* The date the credential list was created
*
* .. php:attr:: date_updated
*
* The date the credential list was updated
*
* .. php:attr:: sid
*
* A 34 character string that identifies this object
*
* .. php:attr:: account_sid
*
* The account that created the credential list
*
* .. php:attr:: friendly_name
*
* The friendly name of the credential list
*
* .. php:attr:: uri
*
* The uri of the credential list
*
* .. php:attr:: subresource_uris
*
* The subresources associated with this credential list (Credentials)
*/
class Services_Twilio_Rest_CredentialList extends Services_Twilio_InstanceResource {
protected function init($client, $uri) {
$this->setupSubresources(
'credentials'
);
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* A single CredentialListMapping
*
* .. php:attr:: date_created
*
* The date this mapping was created
*
* .. php:attr:: date_updated
*
* The date this mapping was updated
*
* .. php:attr:: sid
*
* The sid of this mapping
*
* .. php:attr:: friendly_name
*
* The friendly name of this mapping
*
* .. php:attr:: uri
*
* The uri of this mapping
*
* .. php:attr:: subresource_uris
*
* The subresources associated with this mapping (Credentials)
*/
class Services_Twilio_Rest_CredentialListMapping extends Services_Twilio_InstanceResource {
protected function init($client, $uri) {
$this->setupSubresources(
'credentials'
);
}
}

View File

@ -0,0 +1,24 @@
<?php
class Services_Twilio_Rest_CredentialListMappings extends Services_Twilio_SIPListResource {
/**
* Creates a new CredentialListMapping instance
*
* Example usage:
*
* .. code-block:: php
*
* $client->account->sip->domains->get('SDXXX')->credential_list_mappings->create("CLXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
*
* :param string $credential_list_sid: the sid of the CredentialList you're adding to this domain.
* :param array $params: a single array of parameters which is serialized and
* sent directly to the Twilio API.
*/
public function create($credential_list_sid, $params = array()) {
return parent::_create(array(
'CredentialListSid' => $credential_list_sid,
) + $params);
}
}

View File

@ -0,0 +1,24 @@
<?php
class Services_Twilio_Rest_CredentialLists extends Services_Twilio_SIPListResource {
/**
* Creates a new CredentialList instance
*
* Example usage:
*
* .. code-block:: php
*
* $client->account->sip->credential_lists->create("MyFriendlyName");
*
* :param string $friendly_name: the friendly name of this credential list
* :param array $params: a single array of parameters which is serialized and
* sent directly to the Twilio API.
*/
public function create($friendly_name, $params = array()) {
return parent::_create(array(
'FriendlyName' => $friendly_name,
) + $params);
}
}

View File

@ -0,0 +1,28 @@
<?php
class Services_Twilio_Rest_Credentials extends Services_Twilio_SIPListResource {
/**
* Creates a new Credential instance
*
* Example usage:
*
* .. code-block:: php
*
* $client->account->sip->credential_lists->get('CLXXX')->credentials->create(
* "AwesomeUsername", "SuperSecretPassword",
* );
*
* :param string $username: the username for the new Credential object
* :param string $password: the password for the new Credential object
* :param array $params: a single array of parameters which is serialized and
* sent directly to the Twilio API.
*/
public function create($username, $password, $params = array()) {
return parent::_create(array(
'Username' => $username,
'Password' => $password,
) + $params);
}
}

View File

@ -0,0 +1,6 @@
<?php
class Services_Twilio_Rest_DependentPhoneNumber
extends Services_Twilio_InstanceResource
{
}

View File

@ -0,0 +1,6 @@
<?php
class Services_Twilio_Rest_DependentPhoneNumbers
extends Services_Twilio_ListResource
{
}

View File

@ -0,0 +1,70 @@
<?php
/**
* A single Domain
*
* .. php:attr:: date_created
*
* The date the domain was created
*
* .. php:attr:: date_updated
*
* The date the domain was updated
*
* .. php:attr:: sid
*
* A 34 character string that identifies this object
*
* .. php:attr:: account_sid
*
* The account that created the domain
*
* .. php:attr:: friendly_name
*
* The friendly name of the domain
*
* .. php:attr:: domain_name
*
* The *.sip.twilio domain for the domain
*
* .. php:attr:: auth_type
*
* The auth type used for the domain
*
* .. php:attr:: voice_url
*
* The voice url for the domain
*
* .. php:attr:: voice_fallback_url
*
* The voice fallback url for the domain
*
* .. php:attr:: voice_fallback_method
*
* The voice fallback method for the domain
*
* .. php:attr:: voice_status_callback_url
*
* The voice status callback url for the domain
*
* .. php:attr:: voice_status_callback_method
*
* The voice status_callback_method for the domain
*
* .. php:attr:: uri
*
* The uri of the domain
*
* .. php:attr:: subresource_uris
*
* The subresources associated with this domain (IpAccessControlListMappings, CredentialListMappings)
*
*/
class Services_Twilio_Rest_Domain extends Services_Twilio_InstanceResource {
protected function init($client, $uri) {
$this->setupSubresources(
'ip_access_control_list_mappings',
'credential_list_mappings'
);
}
}

View File

@ -0,0 +1,28 @@
<?php
class Services_Twilio_Rest_Domains extends Services_Twilio_SIPListResource {
/**
* Creates a new Domain instance
*
* Example usage:
*
* .. code-block:: php
*
* $client->account->sip->domains->create(
* "MyFriendlyName", "MyDomainName"
* );
*
* :param string $friendly_name: the friendly name of this domain
* :param string $domain_name: the domain name for this domain
* :param array $params: a single array of parameters which is serialized and
* sent directly to the Twilio API.
*/
public function create($friendly_name, $domain_name, $params = array()) {
return parent::_create(array(
'FriendlyName' => $friendly_name,
'DomainName' => $domain_name,
) + $params);
}
}

View File

@ -0,0 +1,34 @@
<?php
class Services_Twilio_Rest_Feedback extends Services_Twilio_InstanceResource {
public function __construct($client, $uri, $params = array()) {
$this->instance_name = "Services_Twilio_Rest_Feedback";
return parent::__construct($client, $uri, $params);
}
/**
* Create feedback for the parent call
*/
public function create(array $params = array()) {
$params = $this->client->createData($this->uri, $params);
return new $this->instance_name($this->client, $this->uri, $params);
}
/**
* Delete feedback for the parent call
*/
public function delete() {
$this->client->deleteData($this->uri);
}
/**
* Fetch the feedback for the parent call
*/
public function get() {
return new $this->instance_name(
$this->client, $this->uri
);
}
}

View File

@ -0,0 +1,33 @@
<?php
class Services_Twilio_Rest_FeedbackSummary extends Services_Twilio_InstanceResource {
public function __construct($client, $uri, $params = array()) {
$this->instance_name = "Services_Twilio_Rest_FeedbackSummary";
return parent::__construct($client, $uri, $params);
}
/**
* Create feedback summary for calls
*/
public function create(array $params = array()) {
$params = $this->client->createData($this->uri, $params);
return new $this->instance_name($this->client, $this->uri, $params);
}
/**
* Delete a feedback summary
*/
public function delete($sid) {
$this->client->deleteData($this->uri . '/' . $sid);
}
/**
* Get a feedback summary
*/
public function get($sid) {
return new $this->instance_name(
$this->client, $this->uri . '/' . $sid
);
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* An object representing a single phone number. For more
* information, see the `IncomingPhoneNumber Instance Resource
* <http://www.twilio.com/docs/api/rest/incoming-phone-numbers#instance>`_
* documentation.
*
* .. php:attr:: sid
*
* A 34 character string that uniquely idetifies this resource.
*
* .. php:attr:: date_created
*
* The date that this resource was created, given as GMT RFC 2822 format.
*
* .. php:attr:: date_updated
*
* The date that this resource was last updated, given as GMT RFC 2822 format.
*
* .. php:attr:: friendly_name
*
* A human readable descriptive text for this resource, up to 64
* characters long. By default, the FriendlyName is a nicely formatted
* version of the phone number.
*
* .. php:attr:: account_sid
*
* The unique id of the Account responsible for this phone number.
*
* .. php:attr:: phone_number
*
* The incoming phone number. e.g., +16175551212 (E.164 format)
*
* .. php:attr:: api_version
*
* Calls to this phone number will start a new TwiML session with this
* API version.
*
* .. php:attr:: voice_caller_id_lookup
*
* Look up the caller's caller-ID name from the CNAM database (additional charges apply). Either true or false.
*
* .. php:attr:: voice_url
*
* The URL Twilio will request when this phone number receives a call.
*
* .. php:attr:: voice_method
*
* The HTTP method Twilio will use when requesting the above Url. Either GET or POST.
*
* .. php:attr:: voice_fallback_url
*
* The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by Url.
*
* .. php:attr:: voice_fallback_method
*
* The HTTP method Twilio will use when requesting the VoiceFallbackUrl. Either GET or POST.
*
* .. php:attr:: status_callback
*
* The URL that Twilio will request to pass status parameters (such as call ended) to your application.
*
* .. php:attr:: status_callback_method
*
* The HTTP method Twilio will use to make requests to the StatusCallback URL. Either GET or POST.
*
* .. php:attr:: sms_url
*
* The URL Twilio will request when receiving an incoming SMS message to this number.
*
* .. php:attr:: sms_method
*
* The HTTP method Twilio will use when making requests to the SmsUrl. Either GET or POST.
*
* .. php:attr:: sms_fallback_url
*
* The URL that Twilio will request if an error occurs retrieving or executing the TwiML from SmsUrl.
*
* .. php:attr:: sms_fallback_method
*
* The HTTP method Twilio will use when requesting the above URL. Either GET or POST.
*
* .. php:attr:: uri
*
* The URI for this resource, relative to https://api.twilio.com.
*/
class Services_Twilio_Rest_IncomingPhoneNumber
extends Services_Twilio_InstanceResource
{
}

View File

@ -0,0 +1,59 @@
<?php
/**
* For more information, see the
* `IncomingPhoneNumbers API Resource
* <http://www.twilio.com/docs/api/rest/incoming-phone-numbers#local>`_
* documentation at twilio.com.
*/
class Services_Twilio_Rest_IncomingPhoneNumbers extends Services_Twilio_ListResource {
function init($client, $uri) {
$this->setupSubresources(
'local',
'toll_free',
'mobile'
);
}
function create(array $params = array()) {
return parent::_create($params);
}
function getList($type, array $params = array())
{
return $this->client->retrieveData($this->uri . "/$type", $params);
}
/**
* Return a phone number instance from its E.164 representation. If more
* than one number matches the search string, returns the first one.
*
* Example usage:
*
* .. code-block:: php
*
* $number = $client->account->incoming_phone_numbers->getNumber('+14105551234');
* echo $number->sid;
*
* :param string $number: The number in E.164 format, eg "+684105551234"
* :return: A :php:class:`Services_Twilio_Rest_IncomingPhoneNumber` object, or null
* :raises: a A :php:class:`Services_Twilio_RestException` if the number is
* invalid, not provided in E.164 format or for any other API exception.
*/
public function getNumber($number) {
$page = $this->getPage(0, 1, array(
'PhoneNumber' => $number
));
$items = $page->getItems();
if (is_null($items) || empty($items)) {
return null;
}
return $items[0];
}
}
class Services_Twilio_Rest_Local extends Services_Twilio_NumberType { }
class Services_Twilio_Rest_Mobile extends Services_Twilio_NumberType { }
class Services_Twilio_Rest_TollFree extends Services_Twilio_NumberType { }

View File

@ -0,0 +1,40 @@
<?php
/**
* A single IpAccessControlList
*
* .. php:attr:: date_created
*
* The date the ip access control list was created
*
* .. php:attr:: date_updated
*
* The date the ip access control list was updated
*
* .. php:attr:: sid
*
* A 34 character string that identifies this object
*
* .. php:attr:: account_sid
*
* The account that created the ip access control list
*
* .. php:attr:: friendly_name
*
* The friendly name of the ip access control list
*
* .. php:attr:: uri
*
* The uri of the ip access control list
*
* .. php:attr:: subresource_uris
*
* The subresources associated with this ip access control list (IpAddresses)
*/
class Services_Twilio_Rest_IpAccessControlList extends Services_Twilio_InstanceResource {
protected function init($client, $uri) {
$this->setupSubresources(
'ip_addresses'
);
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* A single IpAccessControlListMapping
*
* .. php:attr:: date_created
*
* The date this mapping was created
*
* .. php:attr:: date_updated
*
* The date this mapping was updated
*
* .. php:attr:: sid
*
* The sid of this mapping
*
* .. php:attr:: friendly_name
*
* The friendly name of this mapping
*
* .. php:attr:: uri
*
* The uri of this mapping
*
* .. php:attr:: subresource_uris
*
* The subresources associated with this mapping (IpAddresses)
*/
class Services_Twilio_Rest_IpAccessControlListMapping extends Services_Twilio_InstanceResource {
protected function init($client, $uri) {
$this->setupSubresources(
'ip_addresses'
);
}
}

View File

@ -0,0 +1,25 @@
<?php
class Services_Twilio_Rest_IpAccessControlListMappings extends Services_Twilio_SIPListResource {
/**
* Creates a new IpAccessControlListMapping instance
*
* Example usage:
*
* .. code-block:: php
*
* $client->account->sip->domains->get('SDXXX')->ip_access_control_list_mappings->create("ALXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
*
* :param string $ip_access_control_list_sid: the sid of the IpAccessControList
* you're adding to this domain.
* :param array $params: a single array of parameters which is serialized and
* sent directly to the Twilio API.
*/
public function create($ip_access_control_list_sid, $params = array()) {
return parent::_create(array(
'IpAccessControlListSid' => $ip_access_control_list_sid,
) + $params);
}
}

View File

@ -0,0 +1,27 @@
<?php
class Services_Twilio_Rest_IpAccessControlLists extends Services_Twilio_SIPListResource {
/**
* Creates a new IpAccessControlLists instance
*
* Example usage:
*
* .. code-block:: php
*
* $client->account->sip->ip_access_control_lists->create("MyFriendlyName");
*
* :param string $friendly_name: the friendly name of this ip access control list
* :param array $params: a single array of parameters which is serialized and
* sent directly to the Twilio API.
* :return: the created list
* :rtype: :class:`Services_Twilio_Rest_IpAccessControlList`
*
*/
public function create($friendly_name, $params = array()) {
return parent::_create(array(
'FriendlyName' => $friendly_name,
) + $params);
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* A single IpAddress
*
* .. php:attr:: date_created
*
* The date the IpAddress was created
*
* .. php:attr:: date_updated
*
* The date the IpAddress was updated
*
* .. php:attr:: sid
*
* A 34 character string that identifies this object
*
* .. php:attr:: account_sid
*
* The account that created this credential
*
* .. php:attr:: friendly_name
*
* The friendly name of the IpAddress
*
* .. php:attr:: ip_address
*
* The ip address of this IpAddress object
*
* .. php:attr:: uri
*
* The uri of this IpAddress object
*/
class Services_Twilio_Rest_IpAddress extends Services_Twilio_InstanceResource { }

View File

@ -0,0 +1,33 @@
<?php
class Services_Twilio_Rest_IpAddresses extends Services_Twilio_SIPListResource {
public function __construct($client, $uri) {
$this->instance_name = "Services_Twilio_Rest_IpAddress";
parent::__construct($client, $uri);
}
/**
* Creates a new IpAddress instance
*
* Example usage:
*
* .. code-block:: php
*
* $client->account->sip->ip_access_control_lists->get('ALXXX')->ip_addresses->create(
* "FriendlyName", "127.0.0.1"
* );
*
* :param string $friendly_name: the friendly name for the new IpAddress object
* :param string $ip_address: the ip address for the new IpAddress object
* :param array $params: a single array of parameters which is serialized and
* sent directly to the Twilio API.
*/
public function create($friendly_name, $ip_address, $params = array()) {
return parent::_create(array(
'FriendlyName' => $friendly_name,
'IpAddress' => $ip_address,
) + $params);
}
}

View File

@ -0,0 +1,3 @@
<?php
class Services_Twilio_Rest_Lookups_PhoneNumber extends Services_Twilio_LookupsInstanceResource { }

View File

@ -0,0 +1,3 @@
<?php
class Services_Twilio_Rest_Lookups_PhoneNumbers extends Services_Twilio_LookupsListResource { }

View File

@ -0,0 +1,31 @@
<?php
/**
* A list of :class:`Media <Services_Twilio_Rest_MediaInstance>` objects.
* For the definitive reference, see the `Twilio Media List Documentation
* <https://www.twilio.com/docs/api/rest/media>`_.
*/
class Services_Twilio_Rest_Media extends Services_Twilio_ListResource {
// This is overridden because the list key in the Twilio response
// is "media_list", not "media".
public function getResourceName($camelized = false)
{
if ($camelized) {
return "MediaList";
} else {
return "media_list";
}
}
// We manually set the instance name here so that the parent
// constructor doesn't attempt to figure out it. It would do it
// incorrectly because we override getResourceName above.
public function __construct($client, $uri) {
$this->instance_name = "Services_Twilio_Rest_MediaInstance";
parent::__construct($client, $uri);
}
}

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