/** */ public static function log($poCredentials, $psMsg = "OK") { $laConfig = Config::getAppOptions(); $laLog = $laConfig['log']['log']['access']; $laDb = $laConfig['db'][APP_ENV]; $lnId = null; $lsUsername = null; $lnGroupId = null; if (is_object($poCredentials)) { $lnId = $poCredentials->getId(); $lsUsername = $poCredentials->getUsername(); $lnGroupId = $poCredentials->getUserGroupId(); } else { $lsUsername = $poCredentials; } $lsIp = $_SERVER['REMOTE_ADDR']; $lsSession = session_id(); if (Util::toBoolean($laLog['enable'])) { if ($laLog['output'] == "DB") { $loDb = new Adapter($laDb); $laServer = $_SERVER; $laServer['ACCESS_MSG'] = $psMsg; $lsServer = Json::encode($laServer); $laExtra = array('stSession' => 'stSession', 'stIP' => 'stIP', 'txtServer' => 'txtServer'); $laData = array('stSession' => $lsSession, 'stIP' => $lsIp, 'txtServer' => $lsServer); if ($lnId !== null) { $laExtra['User_id'] = 'User_id'; $laData['User_id'] = $lnId; } $laColumnMap = array('timestamp' => 'dtInsert', 'priority' => 'stPriority', 'message' => 'txtCredentials', 'extra' => $laExtra); $laCredential = array('user' => $lsUsername, 'group' => $lnGroupId); $lsCredential = Json::encode($laCredential); $loWriter = new Writer\Db($loDb, $laLog['table'], $laColumnMap); $loLogger = new Logger(); $loLogger->addWriter($loWriter); $loLogger->info($lsCredential, $laData); } else { $laMessage = array('stIP' => $lsIp, 'stSession' => $lsSession, 'userId' => $lnId, 'user' => $lsUsername, 'group' => $lnGroupId); Event::log($laMessage, Event::INFO, $laLog['fileName'], "STREAM", true); } } }
/** * * @param string $psQuery * - Termo de busca utilizado pelo usuário * @param int $pnResults * - Número de resultados retornados com o termo */ public static function log($psQuery, $pnResults) { $laConfig = Config::getAppOptions(); $laLog = $laConfig['log']['log']['search']; $laDb = $laConfig['db'][APP_ENV]; if (Util::toBoolean($laLog['enable'])) { if ($laLog['output'] == "DB") { $loDb = new Adapter($laDb); $laColumnMap = array('timestamp' => 'dtInsert', 'priority' => 'stPriority', 'message' => 'stQuery', 'extra' => array('numResults' => 'numResults')); $laData = array('numResults' => $pnResults); $loWriter = new Writer\Db($loDb, $laLog['table'], $laColumnMap); $loLogger = new Logger(); $loLogger->addWriter($loWriter); $loLogger->info($psQuery, $laData); } else { $laParamns['userId'] = null; $laParamns['query'] = $psQuery; $laParamns['results'] = $pnResults; Event::log($laParamns, Event::INFO, $laLog['fileName'], "STREAM", true); } } }
/** * */ public function clientSets() { $laFormClientConfig = $this->getFormOptions($this->_sModule); if (is_array($laFormClientConfig) && (isset($laFormClientConfig[$this->_sForm]) && is_array($laFormClientConfig[$this->_sForm]))) { foreach ($laFormClientConfig[$this->_sForm] as $lsField => $laPropertie) { if (isset($laPropertie['disable']) && Util::toBoolean($laPropertie['disable'])) { $this->remove($lsField); } else { unset($laPropertie['disable']); $loElement = $this->get($lsField); if (is_object($loElement) && is_array($laPropertie)) { foreach ($laPropertie as $lsProp => $lmValue) { if ($lsProp == 'value') { $loElement->setValue($lmValue); } elseif ($lsProp == 'label') { $loElement->setLabel($lmValue); } elseif ($lsProp == 'empty_option') { $loElement->setEmptyOption($lmValue); } elseif ($lsProp == 'value_options') { $loElement->setValueOptions($lmValue); } if ($loElement->hasAttribute($lsProp) != null) { $loElement->setAttribute($lsProp, $lmValue); } elseif ($loElement->getOption($lsProp) != null) { $loElement->setOption($lsProp, $lmValue); } } } } } } }
/** * event: gera log de sistema, gravando em banco, arquivo, firebug ou exibindo na tela * * @param string|array $pmParam - array __FILE__,__METHOD__,__LINE__ ... * @param int $pnPriority - EMERG = 0; ALERT = 1; CRIT = 2; ERR = 3; WARN = 4; NOTICE = 5; INFO = 6; DEBUG = 7; * @param string $psOutput - força o nome da tabela ou posfixo do arquivo a ser gravado * @param string $psType - força o tipo de saída: DB ou STREAM */ public static function log($pmParam, $pnPriority = 7, $psOutput = null, $psType = null, $pbSave = false) { $laConfig = Config::getAppOptions(); $laLog = $laConfig['log']['log']['events']; $laDb = $laConfig['db'][APP_ENV]; $lsLogDir = $laConfig['log']['log']['logDir']; $lsTable = $laLog['table']; $lsFilePosfix = "_" . $laLog['fileName']; $lsLine = ""; $lsId = null; if (Util::toBoolean($laLog['enable']) || $pbSave) { $lsIP = $_SERVER['REMOTE_ADDR']; $lsType = $laLog['output']; if ($psType != null) { $lsType = $psType; } if (is_array($pmParam)) { foreach ($pmParam as $lsKey => $lsItem) { if (strtolower($lsKey) == 'userid') { $lsId = $lsItem; continue; } } } $laData = array(); switch ($lsType) { case "DB": if ($psOutput != null) { $lsTable = $psOutput; } $loDb = new Adapter($laDb); $lsLine = Json::encode($pmParam); $lsServer = Json::encode($_SERVER); $laExtra = array('stIP' => 'stIP', 'txtServer' => 'txtServer'); $laData = array('stIP' => $lsIP, 'txtServer' => $lsServer); if ($lsId !== null) { $laExtra['User_id'] = 'User_id'; $laData['User_id'] = $lsId; } $laColumnMap = array('timestamp' => 'dtInsert', 'priority' => 'stPriority', 'message' => 'stMsg', 'extra' => $laExtra); $loWriter = new Writer\Db($loDb, $lsTable, $laColumnMap); break; case "STREAM": $lsLine .= "\t" . $lsIP; if (is_array($pmParam)) { foreach ($pmParam as $lsKey => $lsItem) { $lsLine .= "\t" . $lsItem; if (strtolower($lsKey) == 'userid') { $lsId = $lsItem; } } } else { $lsLine .= "\t" . $pmParam; } if ($psOutput != null) { $lsFilePosfix = "_" . $psOutput; } if (file_exists($lsLogDir)) { $loWriter = new Writer\Stream($lsLogDir . DS . date("Y-m-d") . $lsFilePosfix . ".log"); } break; } $loLogger = new Logger(); $loLogger->addWriter($loWriter); $loLogger->log($pnPriority, $lsLine, $laData); } }
/** * * @param string $psType * @param string $psUrl * @param string $psTable * @param int $pnId */ public static function log($psType, $psUrl, $psTable = null, $pnId = null) { $laConfig = Config::getAppOptions(); $laLog = $laConfig['log']['log'][$psType]; $laDb = $laConfig['db'][APP_ENV]; if (Util::toBoolean($laLog['enable'])) { if ($laLog['output'] == "DB") { $loDb = new Adapter($laDb); $laColumnMap = array('timestamp' => 'dtInsert', 'priority' => 'stPriority', 'message' => 'stUrl', 'extra' => array('numId' => 'numId', 'stTable' => 'stTable')); $laData = array('numId' => $pnId, 'stTable' => $psTable); $loWriter = new Writer\Db($loDb, $laLog['table'], $laColumnMap); $loLogger = new Logger(); $loLogger->addWriter($loWriter); $loLogger->info($psUrl, $laData); } else { $laParamns['userId'] = null; $laParamns['table'] = $psTable; $laParamns['id'] = $pnId; $laParamns['url'] = $psUrl; Event::log($laParamns, Event::INFO, $laLog['fileName'], "STREAM", true); } } }
/** */ public static function showDebug() { $laConfig = Config::getAppOptions(); $laDebug = $laConfig['log']['debug']['PHP']; if (Util::toBoolean($laDebug['enable']) && $laDebug['output'] == "BUFFER") { $loBuffer = Session::getRegister("DEBUG"); echo '<pre style="margin:50px;"><code><fieldset><legend>Onion Debug:</legend>'; if (is_array($loBuffer)) { foreach ($loBuffer as $lsItem) { self::displayDebug(Json::decode($lsItem)); echo "<br/><hr/><br/>"; } } echo '</fieldset></code></pre>'; } Session::clearRegister("DEBUG"); }
public function setContainer($pmBody) { $lsBodyText = ''; $lsBodyHtml = ''; if (is_array($pmBody)) { if (isset($pmBody['text'])) { $lsBodyText = $pmBody['text']; } if (isset($pmBody['html'])) { $lsBodyHtml = $pmBody['html']; } } else { $lsBodyText = $pmBody; } $loText = new Mime\Part($lsBodyText); $loText->type = "text/plain"; $laBody[] = $loText; if (Util::toBoolean($this->_aOptions["html"])) { $loHtml = new Mime\Part($lsBodyHtml); $loHtml->type = "text/html"; $laBody[] = $loHtml; } if (is_array($this->_aFiles)) { foreach ($this->_aFiles as $laFile) { $loAttachment = new Mime\Part(file_get_contents($laFile['tmp_name'])); $loAttachment->type = $laFile['type']; $loAttachment->disposition = 'attachment'; } $laBody[] = $loAttachment; } $loBody = new Mime\Message(); $loBody->setParts($laBody); return $loBody; }
public function calcTime() { $this->_nEndTime = Util::getmicrotime(); $this->_nTime = $this->_nEndTime - $this->_nEndTime; }