Example #1
0
function toUtf8($data)
{
    if (!is_array($data)) {
        return mb_convert_encoding($data, 'UTF-8', 'UTF-8 , ISO-8859-1');
    }
    $return = array();
    foreach ($data as $i => $v) {
        $return[toUtf8($i)] = toUtf8($v);
    }
    return $return;
}
Example #2
0
function toUtf8($data)
{
    if (is_array($data)) {
        $return = array();
        foreach ($data as $i => $v) {
            $return[srtToUtf8($i)] = is_array($v) ? toUtf8($v) : srtToUtf8($v);
        }
        return $return;
    } else {
        return srtToUtf8($data);
    }
}
Example #3
0
function toUtf8($data)
{
    //字符串
    if (!is_array($data)) {
        if ($data === iconv('UTF-8', 'UTF-8//IGNORE', $data)) {
            return $data;
        }
        return getUTFString($data);
    }
    foreach ($data as &$value) {
        $value = toUtf8($value);
    }
    return $data;
}
Example #4
0
 /**
  * Parse xml file.
  *
  * @return array|bool
  */
 public function parse_xml()
 {
     if (preg_match('#(?<open><?xml.*encoding=[\'|"])(?<encoding>.+)(?<close>["|\'].*?>)#', $this->xmldata, $match)) {
         $this->encoding = strtoupper($match['encoding']);
         if (!is_equal($this->encoding, self::UTF8)) {
             $this->xmldata = str_replace($match[0], $match['open'] . self::UTF8 . $match['close'], toUtf8($this->encoding, $this->xmldata));
             $this->encoding = self::UTF8;
         }
     }
     return $this->parse();
 }
Example #5
0
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    ipnLog(mb_detect_encoding($_SERVER['REQUEST_METHOD']));
    ipnLog($_SERVER['REQUEST_METHOD']);
    //Antes de trabalhar com a notificação, precisamos verificar se ela
    //é válida e, se não for, descartar.
    if (!isIPNValid($_POST)) {
        ipnLog("invalid");
        return;
    }
    //Se chegamos até aqui, significa que estamos lidando com uma
    //notificação IPN válida. Agora precisamos verificar se somos o
    //destinatário dessa notificação, verificando o campo receiver_email.
    ipnLog($receiver_email);
    if ($_POST['receiver_email'] == $receiver_email) {
        foreach ($_POST as $p) {
            ipnLog(toUtf8($p));
        }
        //Está tudo correto, somos o destinatário da notificação, vamos
        //gravar um log dessa notificação.
        /*
         *
         *
         */
        //if (logIPN($pdo, $_POST)) {
        //Log gravado, podemos seguir com as regras de negócio para
        //essa notificação.
        //}
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    ipnLog($_SERVER['REQUEST_METHOD']);
 /**
  * Transforme un élément en texte.
  * Cette fonction parcourt récursivement les descendants d'un élément et
  * renvoie la chaîne formée par la concaténation de toutes les valeurs
  * des enfants.
  * @param string|object XML_Tree_Node $element
  * @return string
  */
 function stringValue($element)
 {
     $res = '';
     if (is_object($element)) {
         $res = $this->_tree2text($element);
     } else {
         $res = strval($element);
     }
     $patterns = array("/&#([0-9]+);/e", "/&#x([0-9a-f]+);/e", "/&lt;/", "/&gt;/", "/&amp;/", "/&apos;/", "/&quot;/");
     $replace = array("utf8Chr(intval(\\1))", "utf8Chr(intval(0x\\1))", "<", ">", "&", "'", '"');
     return preg_replace($patterns, $replace, toUtf8($res));
 }
Example #7
0
     if ($_POST['listarTodos'] == 'ALL') {
         $manterTramite['ALL'] = true;
     }
     $rsUnidades = DaoTramite::listTramiteDisponiveis($manterTramite, $_REQUEST['uop']);
     $out = toUtf8($rsUnidades->resultado);
     break;
     /**
      * 
      */
 /**
  * 
  */
 case 'get-unidades-ativas':
     $manterTramite['ID'] = (int) $_POST['idUnidade'];
     $rsUnidades = DaoTramite::listTramiteAtivo($manterTramite);
     $out = toUtf8($rsUnidades->resultado);
     break;
     /**
      * 
      */
 /**
  * 
  */
 case 'get-unidade':
     $idUnidade = (int) $_POST['idUnidade'];
     $nomeUnidade = DaoUnidade::getUnidade($idUnidade, 'NOME');
     if (isset($nomeUnidade) && !empty($nomeUnidade)) {
         $out = array('success' => true, 'nome' => $nomeUnidade);
     } else {
         throw new Exception('Ocorreu algum erro, tente novamente!');
     }