function db_log($sLog = "", $sArquivo = "", $iTipo = 0) { $aDataHora = getdate(); $sPrefixo = sprintf("[%02d/%02d/%04d %02d:%02d:%02d] ", $aDataHora["mday"], $aDataHora["mon"], $aDataHora["year"], $aDataHora["hours"], $aDataHora["minutes"], $aDataHora["seconds"]); $sLog = str_replace("\n", "\n{$sPrefixo}", $sLog); $sOutputLog = $sPrefixo . $sLog . "\n"; if ($iTipo == 0 || $iTipo == 1) { echo toUTF8($sOutputLog); } if ($iTipo == 0 || $iTipo == 2) { if (!empty($sArquivo)) { $fd = fopen($sArquivo, "a+"); if ($fd) { fwrite($fd, $sOutputLog); fclose($fd); } } } return $aDataHora; }
function auditoriaLog($acao, $comando, $device, $login, $nome_completo, $ipaddress, $tela = "") { $acao = toUTF8($acao); $nome_completo = addslashes(toUTF8($nome_completo)); $comando = addslashes($comando); $sql = "SELECT nome FROM colaborador WHERE device = '{$device}'"; $pesq = query($sql); // if(sizeof($pesq) > 0){ // $sql = "INSERT INTO auditoria "; // $sql = $sql . " (acao,comando,device,login,nome_completo,ipaddress,tela,id_colaborador) "; // $sql = $sql . " VALUES "; // $sql = $sql . " ('$acao','$comando','$device','$login','$nome_completo','$ipaddress','$tela',$pesq[0][id_colaborador]); "; // }else{ $sql = "INSERT INTO auditoria "; $sql = $sql . " (acao,comando,device,login,nome_completo,ipaddress) "; $sql = $sql . " VALUES "; $sql = $sql . " ('{$acao}','{$comando}','{$device}','{$login}','{$nome_completo}','{$ipaddress}'); "; // } $audit = query($sql); }
private function parseChapters() { preg_match_all("/cview\\('\\d+-(\\d+)\\.html',\\d+\\);.+>.+\\s(.+)</", $this->html, $chapters, PREG_SET_ORDER); if (!isset($chapters[0]) or !isset($chapters[0][0])) { throw new Exception('Cannot get chapters.'); } $chs = array(); foreach ($chapters as $chapter) { // 8comic's chapter id as array index, chapter name as value. $chs[$chapter[1]] = trim(toUTF8(strip_tags(preg_replace('/script>[^<]+/', "", $chapter[2])))); } return $chs; }
function returnJson($code, $msg = '', $data = array(array())) { // function returnJson($code, $msg='', $data="") { $msg = toUTF8($msg); $json = array(); $result = array(array('code' => $code, 'message' => $msg, 'data' => $data)); array_push($json, $result); // header("Content-Type: application/json; charset=utf-8",true); print json_encode($result); if ($code == -1) { exit; } }
{ switch ($char_code) { case 0: $char = chr(0); case !($char_code & 0xffffff80): // 7 bit $char = chr($char_code); break; case !($char_code & 0xfffff800): // 11 bit $char = chr(0xc0 | $char_code >> 6 & 0x1f) . chr(0x80 | $char_code & 0x3f); break; case !($char_code & 0xffff0000): // 16 bit $char = chr(0xe0 | $char_code >> 12 & 0xf) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); break; case !($char_code & 0xffe00000): // 21 bit $char = chr(0xf0 | $char_code >> 18 & 0x7) . chr(0x80 | $char_code >> 12 & 0x3f) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); break; case !($char_code & 0xfc000000): // 26 bit $char = chr(0xf8 | $char_code >> 24 & 0x3) . chr(0x80 | $char_code >> 18 & 0x3f) . chr(0x80 | $char_code >> 12 & 0x3f) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); default: // 31 bit $char = chr(0xfc | $char_code >> 30 & 0x1) . chr(0x80 | $char_code >> 24 & 0x3f) . chr(0x80 | $char_code >> 18 & 0x3f) . chr(0x80 | $char_code >> 12 & 0x3f) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); } return $char; } echo "\n", toUTF8(65), "\n", toUTF8(233), "\n", toUTF8(1252), "\n", toUTF8(20095), "\n";
$char = chr(0); case !($char_code & 0xffffff80): // 7 bit $char = chr($char_code); break; case !($char_code & 0xfffff800): // 11 bit $char = chr(0xc0 | $char_code >> 6 & 0x1f) . chr(0x80 | $char_code & 0x3f); break; case !($char_code & 0xffff0000): // 16 bit $char = chr(0xe0 | $char_code >> 12 & 0xf) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); break; case !($char_code & 0xffe00000): // 21 bit $char = chr(0xf0 | $char_code >> 18 & 0x7) . chr(0x80 | $char_code >> 12 & 0x3f) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); break; case !($char_code & 0xfc000000): // 26 bit $char = chr(0xf8 | $char_code >> 24 & 0x3) . chr(0x80 | $char_code >> 18 & 0x3f) . chr(0x80 | $char_code >> 12 & 0x3f) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); default: // 31 bit $char = chr(0xfc | $char_code >> 30 & 0x1) . chr(0x80 | $char_code >> 24 & 0x3f) . chr(0x80 | $char_code >> 18 & 0x3f) . chr(0x80 | $char_code >> 12 & 0x3f) . chr(0x80 | $char_code >> 6 & 0x3f) . chr(0x80 | $char_code & 0x3f); } return $char; } echo bin2hex(toUTF8(65)), "\n"; echo bin2hex(toUTF8(233)), "\n"; echo bin2hex(toUTF8(1252)), "\n"; echo bin2hex(toUTF8(20095)), "\n";
function auditoriaLog($acao, $mac_address, $ip_address, $serial_number, $sql, $device, $login, $nome_cracha) { $acao = toUTF8($acao); $nome_cracha = toUTF8($nome_cracha); $audit = query("INSERT INTO auditoria (data_hora,acao,mac_address,ip_address,serial_number,comando,device,login,nome_cracha) VALUES (CURRENT_TIMESTAMP(),'%s','%s','%s','%s','%s','%s','%s','%s')", $acao, $mac_address, $ip_address, $serial_number, $sql, $device, $login, $nome_cracha); }
function escapeJsonString(&$x) { # list from www.json.org: (\b backspace, \f formfeed)#accents !!!! if (is_array($x)) { foreach ($x as &$v) { escapeJsonString($v); } } $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "", "\f"); $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); $x = str_replace($escapers, $replacements, $x); toUTF8($x); return $x; }
public function msg($title, $description, $result = 'ok') { if ($this->_request->isAJAX()) { $this->renderText('{"result":"' . $result . '", "message":"' . toUTF8(t($description)) . '", "title":"' . toUTF8(t($title)) . '"}', 'application/json', 'UTF-8'); } else { msgbox(t($title), t($description)); } }