Ignore:
Timestamp:
04/30/12 15:42:36 (12 years ago)
Author:
acoutinho
Message:

Ticket #2672 - Erro ao importar alguns ics vindos de outros aplicativos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/converter.php

    r5916 r6066  
    33require_once 'api/controller.php'; 
    44 
    5 $method =  isset($_REQUEST['analize']) && $_REQUEST['analize'] ? 'analize' : 'parse'; 
     5$method = isset($_REQUEST['analize']) && $_REQUEST['analize'] ? 'analize' : 'parse'; 
    66 
    7         $file = false; 
    8          
    9         if(isset($_FILES['files'] )) 
    10                 $file = file_get_contents( $_FILES['files']['tmp_name'][0], $_FILES['files']['size'][0] ); 
    11         else if(isset( $_REQUEST['data'] ))  
    12                 $file = $_REQUEST['data']; 
    13         else if(isset($_FILES['data'])) 
    14                 $file = file_get_contents($_FILES['data']['tmp_name']) ; 
     7$file = false; 
    158 
    16         if($file) 
    17                 $args = Controller::call( $method, 
     9if (isset($_FILES['files'])) 
     10    $file = file_get_contents($_FILES['files']['tmp_name'][0], $_FILES['files']['size'][0]); 
     11else if (isset($_REQUEST['data'])) 
     12    $file = $_REQUEST['data']; 
     13else if (isset($_FILES['data'])) 
     14    $file = file_get_contents($_FILES['data']['tmp_name']); 
    1815 
    19                                 array( 'service' => $_REQUEST['type'] ), 
     16if ($file) 
     17    $args = Controller::call($method, array('service' => $_REQUEST['type']), $file, $_REQUEST['params'] 
     18    ); 
     19else 
     20    $args = array('Error' => 'No source file'); 
    2021 
    21                                 $file, $_REQUEST['params']  
    22                         ); 
    23         else 
    24                 $args = array('Error' => 'No source file'); 
     22if (isset($args[0]) && empty($args[0])) 
     23    echo json_encode($args); 
     24else { 
     25    if (!isset($_REQUEST['readable']) || !$_REQUEST['readable']) { 
     26        require_once 'Sync.php'; 
     27        $args = toUtf8($args); 
     28        echo json_encode($args); 
     29    }else 
     30        print_r(serialize($args)); 
     31} 
    2532 
    26         if( isset($args[0]) && empty($args[0]) ) 
    27                 echo json_encode($args); 
    28         else{ 
    29                 if(!isset($_REQUEST['readable']) || !$_REQUEST['readable']){ 
    30                         require_once 'Sync.php';                         
    31                         $args = toUtf8($args); 
    32                         echo json_encode($args); 
    33                 }else 
    34                         print_r(serialize($args)); 
    35         } 
     33function srtToUtf8($data) { 
     34    return mb_convert_encoding($data, 'UTF-8', 'UTF-8 , ISO-8859-1'); 
     35} 
    3636 
    37         function srtToUtf8($data){ 
    38                 return mb_convert_encoding( $data , 'UTF-8' , 'UTF-8 , ISO-8859-1' ); 
    39         } 
     37function toUtf8($data) { 
     38    if (is_array($data)) { 
     39        $return = array(); 
     40        foreach ($data as $i => $v) 
     41            $return[srtToUtf8($i)] = (is_array($v)) ? toUtf8($v) : srtToUtf8($v); 
    4042 
    41         function toUtf8($data){ 
    42                 if(is_array($data)){    
    43                         $return = array(); 
    44                         foreach ($data as $i => $v) 
    45                            $return[srtToUtf8($i)] = (is_array($v)) ? toUtf8($v) : srtToUtf8($v); 
    46                          
    47                         return $return; 
    48                 }else 
    49                    return srtToUtf8($data); 
    50         } 
    51          
    52          
     43        return $return; 
     44    }else 
     45        return srtToUtf8($data); 
     46} 
     47 
    5348?> 
Note: See TracChangeset for help on using the changeset viewer.