Initial checkin v13.0

This commit is contained in:
Thilina Hasantha
2015-10-10 20:18:50 +05:30
parent 5fdd19b2c5
commit eb3439b29d
1396 changed files with 318492 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?php
if(!class_exists('CalendarTools')) {
class CalendarTools
{
const MODE_MONTH = "MONTH";
const MODE_WEEK = "WEEK";
const MODE_DAY = "DAY";
public static function getCalendarMode($start, $end)
{
$diff = (intval($end) - intval($start)) / (60 * 60 * 24);
if ($diff > 8) {
return CalendarTools::MODE_MONTH;
} else if ($diff > 2) {
return CalendarTools::MODE_WEEK;
} else {
return CalendarTools::MODE_DAY;
}
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
if(!class_exists('InputCleaner')){
class InputCleaner{
public static function cleanParameters($input){
foreach($input as $key => $value) {
$cleaned = self::cleanParameter($value);
$input[$key] = $cleaned;
}
return $input;
}
public static function cleanParameter($val){
$val = strip_tags($val, TAGS_TO_PRESERVE);
/*
/ # Start Pattern
< # Match '<' at beginning of tags
( # Start Capture Group $1 - Tag Name
[a-z] # Match 'a' through 'z'
[a-z0-9]* # Match 'a' through 'z' or '0' through '9' zero or more times
) # End Capture Group
[^>]*? # Match anything other than '>', Zero or More times, not-greedy (wont eat the /)
(\/?) # Capture Group $2 - '/' if it is there
> # Match '>'
/i # End Pattern - Case Insensitive
*/
$val = preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $val);
return $val;
}
}
}

41
src/utils/LogManager.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
if(!class_exists('LogManager')){
class LogManager{
private static $me;
private $log;
private function __construct(){
}
public static function getInstance(){
if(empty(self::$me)){
self::$me = new LogManager();
self::$me->log = new Logger(APP_NAME);
if(is_writable(ini_get('error_log'))){
self::$me->log->pushHandler(new StreamHandler(ini_get('error_log'), LOG_LEVEL));
}else{
self::$me->log->pushHandler(new StreamHandler(CLIENT_BASE_PATH.'data/app.log', LOG_LEVEL));
}
}
return self::$me;
}
public function info($message){
$this->log->addInfo($message);
}
public function debug($message){
$this->log->addDebug($message);
}
public function error($message){
$this->log->addError($message);
}
}
}

View File

@@ -0,0 +1,22 @@
<?php
if(!class_exists('SessionUtils')){
class SessionUtils{
public static function getSessionObject($name){
session_start();
if(isset($_SESSION[$name.CLIENT_NAME])){
$obj = $_SESSION[$name.CLIENT_NAME];
}
session_write_close();
if(empty($obj)){
return null;
}
return json_decode($obj);
}
public static function saveSessionObject($name,$obj){
session_start();
$_SESSION[$name.CLIENT_NAME] = json_encode($obj);
session_write_close();
}
}
}