/system/engine/class/public_engine.class.php
PHP | 452 lines | 379 code | 21 blank | 52 comment | 56 complexity | 0acc1eb279c83af22f870e8ed254d37d MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- ###########################################################################################################################
- ## File name : public_engine.class.php
- ## Author : Tri Hartanto
- ## Site : trihartanto.com
- ## Framework : thtech ver.3
- ## CMS : triCMS ver.3
- ## Engine : thtech ver.3
- ## Engine type : Program type
- ## License : GPL
- ## Create Date : 28 September 2011
- ## Modified Date : 03 February 2013
- ## File Description : This file contains public engine class to process the framework and CMS system.
- ##
- ## This file is part of THTech Frameworks.
- ##
- ## THTech Frameworks is free software: you can redistribute it and/or modify
- ## it under the terms of the GNU General Public License as published by
- ## the Free Software Foundation, either version 3 of the License, or
- ## (at your option) any later version.
- ##
- ## THTech Frameworks is distributed in the hope that it will be useful,
- ## but WITHOUT ANY WARRANTY; without even the implied warranty of
- ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ## GNU General Public License for more details.
- ##
- ## You should have received a copy of the GNU General Public License
- ## along with THTech Frameworks. If not, see <http://www.gnu.org/licenses/>.
- ##
- ###########################################################################################################################
- class System_Public_Engine_Class
- {
- public function __call($name,$arguments)
- {
- return $this->loadSysPubEngineLibrary(array('libraryName'=>$name,'libraryArguments'=>$arguments,'ismethod'=>true));
- }
-
- public function __get($var=NULL)
- {
- return $this->loadSysPubEngineLibrary(array('libraryName'=>$var,'ismethod'=>false));
- }
-
- private function loadSysPubEngineLibrary($data=NULL)
- {
- $libraryName = explode('_',$data['libraryName'],2);
- $libraryFile = dirname(__FILE__).'/../syspubengine_library/'.$libraryName[0].'.class.php';
- $libraryClass = ucfirst($libraryName[0]).'_SysPubEngine_Library';
- if(!isset($this->$libraryClass) and file_exists($libraryFile))
- {
- include_once($libraryFile);
- if(class_exists($libraryClass))
- {
- $this->$libraryClass = new $libraryClass();
- }
- }
- if($data['ismethod']===true and method_exists($this->$libraryClass,$libraryName[1]))
- {
- return call_user_func_array(array($this->$libraryClass,$libraryName[1]),$data['libraryArguments']);
- }
- else if($data['ismethod']===false and isset($this->$libraryClass->$libraryName[1]))
- {
- return $this->$libraryClass->$libraryName[1];
- }
- return false;
- }
-
- public function addhtmlhead($data=NULL)
- {
- $GLOBALS['_SysEngine']->addhtmlhead($data);
- }
-
- public function createanchor($data=NULL)
- {
- $JSONData = (!empty($data['attribute']) and !is_array($data['attribute']))?json_decode($data['attribute'],true):NULL;
- $AnchorAttribute = (is_array($JSONData))?$JSONData:((!empty($data['attribute']))?$data['attribute']:NULL);
- $attribute = '';
- if(!empty($AnchorAttribute) and is_array($AnchorAttribute))
- {
- $AnchorAttribute['title'] = (isset($AnchorAttribute['title']))?$AnchorAttribute['title']:$data['title'];
- foreach($AnchorAttribute as $AnchorAttKey=>$AnchorAttVal)
- {
- if(strtolower($AnchorAttKey)!='href')
- {
- $attribute .= ' '.$AnchorAttKey.'="'.$AnchorAttVal.'" ';
- }
- }
- }
- else
- {
- $attribute .= ' '.$AnchorAttribute.' ';
- }
- $AnchorURL = (!empty($data['URLData']))?$this->createurl(array('URLData'=>$data['URLData'])):NULL;
- $html = '';
- $html .= '<a '.((!empty($AnchorURL))?'href="'.$AnchorURL.'"':'').' '.$attribute.'>';
- $html .= ' '.$data['title'].'';
- $html .= '</a>';
- return $html;
- }
-
- public function redirect($data=NULL)
- {
- $html = '';
- $location = $this->createurl($data);
- if(!empty($location))
- {
- $html = header('Location: '.$location.'');
- }
- return $html;
- }
-
- public function createurl($data=NULL)
- {
- $URLData = (!empty($data['URLData']))?$data['URLData']:((isset($data['URLApp']) or isset($data['URLLink']) or isset($data['URLString']))?$data:NULL);
- #################################################################################
- $_URLDecode = (empty($data['_URLDecode']))?$GLOBALS['_URLDecode']:$data['_URLDecode'];
- ################# Get _AppData used for program location ################
- $_AppData = (empty($data['_AppData']))?$GLOBALS['_AppData']:$data['_AppData'];
- #################################################################################
- $URLApp = (isset($URLData['URLApp']))?$URLData['URLApp']:((!empty($_URLDecode['URLApp']))?$_URLDecode['URLApp']:((!empty($_AppData[0]['uprgm_name']))?$_AppData[0]['uprgm_name']:NULL));
- $URLLink = (isset($URLData['URLLink']))?$URLData['URLLink']:((!empty($_URLDecode['URLLink']))?$_URLDecode['URLLink']:((!empty($_NavData[0]['nav_name']))?$_NavData[0]['nav_name']:NULL));
- $URLExtPath = (isset($URLData['URLExtPath']))?$URLData['URLExtPath']:((!empty($_URLDecode['URLExtPath']))?$_URLDecode['URLExtPath']:((!empty($_NavData[0]['nav_extpath']))?$_NavData[0]['nav_extpath']:NULL));
- $URLString = (isset($URLData['URLString']))?$URLData['URLString']:((!empty($_URLDecode['URLString']))?$_URLDecode['URLString']:((!empty($_NavData[0]['nav_string']))?$_NavData[0]['nav_string']:NULL));
- $URLIndex = (isset($URLData['URLIndex']))?$URLData['URLIndex']:((!empty($_URLDecode['URLIndex']))?$_URLDecode['URLIndex']:((!empty($_AppData[0]['type_index']))?$_AppData[0]['type_index']:NULL));
- $html = '';
- $html = HTTP_ROOT_DIR;
- $html .= ((FRIENDLYURLINDEX===true or !empty($URLData['URLIndex'])) and (!empty($URLIndex)))?'/'.$URLIndex:NULL;
- $html .= ($URLApp!=NULL)?'/'.$URLApp:NULL;
- $html .= ($URLLink!=NULL)?'/'.$URLLink:NULL;
- if(!empty($URLExtPath))
- {
- $URLExtPath = (!is_array($URLExtPath))?json_decode($URLExtPath,true):$URLExtPath;
- foreach($URLExtPath as $val)
- {
- $html .= (!empty($val))?'/'.$val:'';
- }
- }
- if(!empty($URLString))
- {
- $loop = 0;
- $URLString = (!is_array($URLString))?json_decode($URLString,true):$URLString;
- foreach($URLString as $key=>$val)
- {
- $loop++;
- $html .= (!empty($val))?((($loop==1)?'?':'&').$key.'='.$val):'';
- }
- }
- return $html;
- }
-
- public function syssession($data=NULL)
- {
- @session_start();
- #################################################################################
- $_AppData = (!empty($GLOBALS['_AppData']))?$GLOBALS['_AppData']:((!empty($data['_AppData']))?$data['_AppData']:array());unset($data['_AppData']);
- #################################################################################
- $action = (!empty($data['action']))?$data['action']:'get';unset($data['action']);
- $timeout = (!empty($data['timeout']))?$data['timeout']:NULL;unset($data['timeout']);
- $syslogged = $syssession = array();
- if(!empty($data))
- {
- foreach($data as $key=>$val)
- {
- if($key === 'syslogged')
- {
- $syslogged = $this->setsyslogged(array('_AppData'=>$_AppData,'action'=>$action,'syslogged'=>$val));
- }
- else
- {
- $syssession = $this->setsyssession(array('_AppData'=>$_AppData,'action'=>$action,'key'=>$key,'val'=>$val));
- }
- }
- }
- $syssession = (!empty($syslogged) and !empty($syssession))?array_merge_recursive($syslogged,$syssession):((!empty($syslogged))?$syslogged:$syssession);
- return $syssession;
- }
-
- private function setsyssession($data=NULL)
- {
- #################################################################################
- $_AppData = $data['_AppData'];unset($data['_AppData']);
- #################################################################################
- $SessionData = false;
- if(!empty($data))
- {
- //$syssession = (!empty($data['val']))?$data['val']:$_SESSION[$data['key']];
- $syssession = (isset($_SESSION[$data['key']]))?$_SESSION[$data['key']]:$data['val'];
- $data['syssession'] = (!empty($data['val']))?$data['val']:$syssession;
- if($data['action']==='set')
- {
- if(!empty($data['syssession']))
- {
- foreach($data['syssession'] as $key=>$val)
- {
- //if(!in_array($val,$syssession))
- //{
- $_SESSION[$data['key']][$key] = $val;
- //}
- }
- }
- }
- else if($data['action']==='get')
- {
- if(!empty($data['syssession']))
- {
- foreach($data['syssession'] as $key=>$val)
- {
- if(isset($_SESSION[$data['key']][$val]))
- {
- $SessionData[$data['key']][$val] = $_SESSION[$data['key']][$val];
- }
- else if(isset($_SESSION[$data['key']]) and in_array($val,$syssession))
- {
- $SessionData[$data['key']][$key] = $_SESSION[$data['key']][$key];
- }
- }
- }
- }
- else if($data['action']==='unset')
- {
- if(isset($_SESSION[$data['key']]) and !empty($data['syssession']))
- {
- foreach($data['syssession'] as $key=>$val)
- {
- if(isset($_SESSION[$data['key']][$val]))
- {
- unset($_SESSION[$data['key']][$val]);
- }
- else if(in_array($val,$syssession))
- {
- unset($_SESSION[$data['key']][$key]);
- }
- }
- }
- else if(isset($_SESSION[$data['key']]))
- {
- unset($_SESSION[$data['key']]);
- }
- }
- }
- return $SessionData;
- }
-
- private function setsyslogged($data=NULL)
- {
- #################################################################################
- $_AppData = $data['_AppData'];unset($data['_AppData']);
- #################################################################################
- $SessionData = array();
- if(!empty($data) and !empty($_AppData))
- {
- $syslogged = array('iprgm','uprgm','global');
- $data['syslogged'] = (!empty($data['syslogged']))?$data['syslogged']:$syslogged;
- if($data['action']=='set')
- {
- foreach($data['syslogged'] as $key=>$val)
- {
- if(in_array($val,$syslogged))
- {
- $keyset = ($val!='global')?$_AppData[0][$val.'_name'].'_'.$val.'logged':'globallogged';
- $_SESSION['_SysLogged'][$keyset] = true;
- }
- }
- }
- else if($data['action']=='get')
- {
- foreach($data['syslogged'] as $key=>$val)
- {
- if(in_array($val,$syslogged))
- {
- $keyget = ($val!='global')?$_AppData[0][$val.'_name'].'_'.$val.'logged':'globallogged';
- if(isset($_SESSION['_SysLogged'][$keyget]))
- {
- $SessionData[$keyget] = $_SESSION['_SysLogged'][$keyget];
- }
- else
- {
- $SessionData[$keyget] = false;
- }
- }
- }
- }
- else if($data['action']=='unset')
- {
- foreach($data['syslogged'] as $key=>$val)
- {
- if(in_array($val,$syslogged))
- {
- $keyget = ($val!='global')?$_AppData[0][$val.'_name'].'_'.$val.'logged':'globallogged';
- if(isset($_SESSION['_SysLogged'][$keyget]))
- {
- unset($_SESSION['_SysLogged'][$keyget]);
- }
- }
- }
- }
- }
- return $SessionData;
- }
-
- public function upload($data=NULL)
- {
- $UploadData = $data['UploadData'];
- $status = array();
- $NewFileName = '';
- if(!empty($_FILES) and is_array($_FILES))
- {
- foreach($_FILES as $key=>$val)
- {
- $UploadData['overwrite'][$key] = false;
- $UploadData['overwrite'] = false;
- $CountFiles[$key] = count($val['name']);
- if(is_array($val['name']) and !empty($_FILES[$key]["tmp_name"]))
- {
- for($a=0;$a<$CountFiles[$key];$a++)
- {
- $NewFileName[$key][$a] = (((!empty($UploadData['filename'][$a]) and is_array($UploadData['filename'])) or (!empty($UploadData['filename']) and !is_array($UploadData['filename'])) or (!empty($UploadData['filename'][$key][$a]) and is_array($UploadData['filename'][$key])) or (!empty($UploadData['filename'][$key]) and !is_array($UploadData['filename'][$key])))?((!empty($UploadData['filename'][$key][$a]) and is_array($UploadData['filename'][$key]))?$UploadData['filename'][$key][$a]:((!empty($UploadData['filename'][$key]) and !is_array($UploadData['filename'][$key]))?$UploadData['filename'][$key]:((is_array($UploadData['filename']))?$UploadData['filename'][$a]:$UploadData['filename']))):$_FILES[$key]["name"][$a]);
- $NewFilePath[$key][$a] = (((!empty($UploadData['filepath'][$a]) and is_array($UploadData['filepath'])) or (!empty($UploadData['filepath']) and !is_array($UploadData['filepath'])) or (!empty($UploadData['filepath'][$key][$a]) and is_array($UploadData['filepath'][$key])) or (!empty($UploadData['filepath'][$key]) and !is_array($UploadData['filepath'][$key])))?((!empty($UploadData['filepath'][$key][$a]) and is_array($UploadData['filepath'][$key]))?$UploadData['filepath'][$key][$a]:((!empty($UploadData['filepath'][$key]) and !is_array($UploadData['filepath'][$key]))?$UploadData['filepath'][$key]:((is_array($UploadData['filepath']))?$UploadData['filepath'][$a]:$UploadData['filepath']))):SYSTEM_TEMPORARY_DIR.'/');
- $NewFileFullPath[$key][$a] = (((!empty($UploadData['filefullpath'][$a]) and is_array($UploadData['filefullpath'])) or (!empty($UploadData['filefullpath']) and !is_array($UploadData['filefullpath'])) or (!empty($UploadData['filefullpath'][$key][$a]) and is_array($UploadData['filefullpath'][$key])) or (!empty($UploadData['filefullpath'][$key]) and !is_array($UploadData['filefullpath'][$key])))?((!empty($UploadData['filefullpath'][$key][$a]) and is_array($UploadData['filefullpath'][$key]))?$UploadData['filefullpath'][$key][$a]:((!empty($UploadData['filefullpath'][$key]) and !is_array($UploadData['filefullpath'][$key]))?$UploadData['filefullpath'][$key]:((is_array($UploadData['filefullpath']))?$UploadData['filefullpath'][$a]:$UploadData['filefullpath']))):$NewFilePath[$key][$a].$NewFileName[$key][$a]);
- if(((((!empty($UploadData['overwrite'][$key][$a]))?$UploadData['overwrite'][$key][$a]:((!empty($UploadData['overwrite'][$key]))?$UploadData['overwrite'][$key]:$UploadData['overwrite']))==true)?true:!file_exists($NewFileFullPath[$key][$a])) and ((!empty($UploadData['type'][$key]) and is_array($UploadData['type'][$key][$a]))?in_array($_FILES[$key]["type"][$a],$UploadData['type'][$key][$a]):((!empty($UploadData['type'][$key]) and is_array($UploadData['type'][$key]))?in_array($_FILES[$key]["type"][$a],$UploadData['type'][$key]):((!empty($UploadData['type']) and is_array($UploadData['type']))?in_array($_FILES[$key]["type"][$a],$UploadData['type']):true))) and ((!empty($UploadData['size'][$key][$a]))?($_FILES[$key]["size"][$a] <= $UploadData['size'][$key][$a]):((!empty($UploadData['size'][$key]))?($_FILES[$key]["size"][$a] <= $UploadData['size'][$key]):((!empty($UploadData['size']))?($_FILES[$key]["size"][$a] <= $UploadData['size']):true))) and !empty($_FILES[$key]["tmp_name"][$a]))
- {
- //echo $a.').'.$_FILES[$key]["tmp_name"][$a].'<=>'.$NewFileFullPath[$a].'<br>';
- move_uploaded_file($_FILES[$key]["tmp_name"][$a],$NewFileFullPath[$a]);
- $status[$key][$a] = true;
- }
- else
- {
- $status[$key][$a] = false;
- }
- //unset($FileName,$FilePath,$FullPath);
- }
- }
- else if(!is_array($val['name']) and !empty($_FILES[$key]["tmp_name"]))
- {
- $NewFileName[$key] = ((!empty($UploadData['filename'][$key]) and !is_array($UploadData['filename'][$key]))?$UploadData['filename'][$key]:((!empty($UploadData['filename']) and !is_array($UploadData['filename']))?$UploadData['filename']:((!empty($_POST['filename']))?$_POST['filename']:$_FILES[$key]["name"])));
- $NewFilePath[$key] = ((!empty($UploadData['filepath'][$key]) and !is_array($UploadData['filepath'][$key]))?$UploadData['filepath'][$key]:((!empty($UploadData['filepath']) and !is_array($UploadData['filepath']))?$UploadData['filepath']:((!empty($_POST['filepath']))?$_POST['filepath']:SYSTEM_TEMPORARY_DIR.'/')));
- $NewFileFullPath[$key] = ((!empty($UploadData['filefullpath'][$key]) and !is_array($UploadData['filefullpath'][$key]))?$UploadData['filefullpath'][$key]:((!empty($UploadData['filefullpath']) and !is_array($UploadData['filefullpath']))?$UploadData['filefullpath']:((!empty($_POST['filefullpath']))?$_POST['filefullpath']:$NewFilePath[$key].$NewFileName[$key])));
- if(((((!empty($UploadData['overwrite'][$key]))?$UploadData['overwrite'][$key]:$UploadData['overwrite'])==true)?true:!file_exists($NewFileFullPath[$key])) and ((!empty($UploadData['type'][$key]) and is_array($UploadData['type'][$key]))?in_array($_FILES[$key]["type"],$UploadData['type'][$key]):((!empty($UploadData['type']) and is_array($UploadData['type']))?in_array($_FILES[$key]["type"],$UploadData['type']):true)) and (!empty($UploadData['size'])?($_FILES[$key]["size"] <= $UploadData['size']):true) and !empty($_FILES[$key]["tmp_name"]))
- {
- //echo $key.').'.$_FILES[$key]["tmp_name"].'<=>'.$NewFileFullPath.'<br>';
- move_uploaded_file($_FILES[$key]["tmp_name"],$NewFileFullPath);
- $status[$key] = true;
- }
- else
- {
- $status[$key] = false;
- }
- }
- }
- }
- $DataArray = array('FileName'=>((!empty($NewFileName))?$NewFileName:NULL),'FilePath'=>((!empty($NewFilePath))?$NewFilePath:NULL),'FileFullPath'=>((!empty($NewFileFullPath))?$NewFileFullPath:NULL),'FileCount'=>((!empty($CountFiles))?$CountFiles:NULL),'status'=>$status);
- return $DataArray;
- }
-
- public function scandirectory($data=NULL)
- {
- $ScanMode = (isset($data['scanmode']))?$data['scanmode']:NULL;
- $ScanDirResult = array();
- $ScanDir = scandir($data['directory']);
- $DefaultExclude = array('.','..');
- $Exclude = (!empty($Exclude) and is_array($data['exclude']))?$data['exclude']:array();
- $Exclude = array_merge($DefaultExclude,$Exclude);
- if($ScanMode != 'plain')
- {
- if(!empty($ScanDir) and is_array($ScanDir))
- {
- foreach($ScanDir as $key=>$val)
- {
- if(!in_array($val,$Exclude))
- {
- $ScanDirResult[] = $val;
- }
- }
- }
- }
- else if($ScanMode == 'plain')
- {
- $ScanDirResult = $ScanDir;
- }
- return $ScanDirResult;
- }
-
- public function sendmail($data=NULL)
- {
- $_LibPHPMailer = $GLOBALS['_LibPHPMailer'];
- $_ProgramConfig = (isset($GLOBALS['_SysEngine']->_CurProgramConfig['email']) and !empty($GLOBALS['_SysEngine']->_CurProgramConfig['email']))?$GLOBALS['_SysEngine']->_CurProgramConfig['email']:NULL;
- //print_r($_ProgramConfig);
- $mail = $_LibPHPMailer;
- $body = ((!empty($data['emailBody']))?$data['emailBody']:((!empty($_ProgramConfig['emailBody']))?$_ProgramConfig['emailBody']:'Email'));
-
- $mail->IsSMTP(); // telling the class to use SMTP
- $mail->Host = ((!empty($data['emailHost']))?$data['emailHost']:((!empty($_ProgramConfig['emailHost']))?$_ProgramConfig['emailHost']:EMAIL_HOST)); // SMTP server
- //$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
- // 1 = errors and messages
- // 2 = messages only
- $mail->SMTPAuth = true; // enable SMTP authentication
- $mail->Port = ((!empty($data['emailPort']))?$data['emailPort']:((!empty($_ProgramConfig['emailPort']))?$_ProgramConfig['emailPort']:EMAIL_PORT)); // set the SMTP port for the GMAIL server
- $mail->Username = ((!empty($data['emailUsername']))?$data['emailUsername']:((!empty($_ProgramConfig['emailUsername']))?$_ProgramConfig['emailUsername']:EMAIL_USERNAME)); // SMTP account username
- $mail->Password = ((!empty($data['emailPassword']))?$data['emailPassword']:((!empty($_ProgramConfig['emailPassword']))?$_ProgramConfig['emailPassword']:EMAIL_PASSWORD)); // SMTP account password
-
- $CheckEmail = explode('@',((!empty($data['emailSentTo']['address']))?$data['emailSentTo']['address']:((!empty($_ProgramConfig['emailSentTo']['address']))?$_ProgramConfig['emailSentTo']['address']:'')));
- if(!empty($CheckEmail[1]))
- {
- $CheckEmailDomain = explode('.',$CheckEmail[1]);
- }
-
- $mail->SetFrom(((!empty($data['emailSentFrom']['address']))?$data['emailSentFrom']['address']:((!empty($_ProgramConfig['emailSentFrom']['address']))?$_ProgramConfig['emailSentFrom']['address']:EMAIL_ADDRESS)), ((!empty($data['emailSentFrom']['title']))?$data['emailSentFrom']['title']:((!empty($_ProgramConfig['emailSentFrom']['title']))?$_ProgramConfig['emailSentFrom']['title']:DEFAULT_EMAIL_TITLE)));
-
- $mail->AddReplyTo(((!empty($data['emailReplyTo']['address']))?$data['emailReplyTo']['address']:((!empty($_ProgramConfig['emailReplyTo']['address']))?$_ProgramConfig['emailReplyTo']['address']:EMAIL_ADDRESS)),((!empty($data['emailReplyTo']['title']))?$data['emailReplyTo']['title']:((!empty($_ProgramConfig['emailReplyTo']['title']))?$_ProgramConfig['emailReplyTo']['title']:DEFAULT_EMAIL_TITLE)));
-
- $mail->Subject = (!empty($data['emailSubject'])?$data['emailSubject']:((!empty($_ProgramConfig['emailSubject']))?$_ProgramConfig['emailSubject']:NULL));
-
- //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
-
- $mail->MsgHTML($body);
- //echo (!empty($data['emailSentTo']['address']))?$data['emailSentTo']['address']:((!empty($_ProgramConfig['emailSentTo']['address']))?$_ProgramConfig['emailSentTo']['address']:NULL);
- $mail->AddAddress(((!empty($data['emailSentTo']['address']))?$data['emailSentTo']['address']:((!empty($_ProgramConfig['emailSentTo']['address']))?$_ProgramConfig['emailSentTo']['address']:NULL)),((!empty($data['emailSentTo']['title']))?$data['emailSentTo']['title']:((!empty($_ProgramConfig['emailSentTo']['title']))?$_ProgramConfig['emailSentTo']['title']:NULL)));
- $mail->AddBCC(((!empty($data['emailBCC']['address']))?$data['emailBCC']['address']:((!empty($_ProgramConfig['emailBCC']['address']))?$_ProgramConfig['emailBCC']['address']:NULL)),((!empty($data['emailBCC']['title']))?$data['emailBCC']['title']:((!empty($_ProgramConfig['emailBCC']['title']))?$_ProgramConfig['emailBCC']['title']:NULL)));
- if(!$mail->Send() and (empty($CheckEmail[1]) and empty($CheckEmailDomain[1])))
- {
- $error = "Mailer Error: ".$mail->ErrorInfo;
- $state = false;
- }
- else
- {
- $error = false;
- $state = true;
- }
- return array('emailstatus'=>$state,'error'=>$error);
- }
-
- public function timezoneconverter($data=NULL)
- {
- $defaulttimezone = date('e',time());
- $fromzone = (isset($data['from']))?$data['from']:$defaulttimezone;
- $date = new DateTime($data['datetime'],new DateTimeZone($fromzone));
- date_default_timezone_set($fromzone);//set from time zone
- $fromdate = $date->format((!empty($fromdateformat))?$fromdateformat:(($dateformat)?$dateformat:'Y-m-d'));
- $fromtime = $date->format((!empty($fromtimeformat))?$fromtimeformat:(($timeformat)?$timeformat:'H:i:s'));
- $fromunixtime = mktime($date->format('H'),$date->format('i'),$date->format('s'),$date->format('m'),$date->format('d'),$date->format('Y'));
-
- $tozone = (!empty($to))?$to:$defaulttimezone;
- date_default_timezone_set($tozone);//set to timezone
- $date->setTimeZone(new DateTimeZone($tozone));
- $todate = $date->format((!empty($todateformat))?$todateformat:(($dateformat)?$dateformat:'Y-m-d'));
- $totime = $date->format((!empty($totimeformat))?$totimeformat:(($timeformat)?$timeformat:'H:i:s'));
- $tounixtime = mktime($date->format('H'),$date->format('i'),$date->format('s'),$date->format('m'),$date->format('d'),$date->format('Y'));
- //echo $date->format('d-m-Y H:i:s P e');
- date_default_timezone_set($defaulttimezone);//backit again to default system timezone
- return array('fromzone'=>$fromzone,'fromdate'=>$fromdate,'fromtime'=>$fromtime,'fromunixtime'=>$fromunixtime,'tozone'=>$tozone,'todate'=>$todate,'totime'=>$totime,'tounixtime'=>$fromunixtime);
- }
- }
- ?>