Пример #1
0
	public function test_check_utf8()
	{
	    $this->assertTrue(test_check_utf8());

            $utf8_str = file_get_contents(dirname(__FILE__) . "/../tools/utf8_str.txt");
	    $this->assertTrue(check_utf8($utf8_str));
            $iso_str = file_get_contents(dirname(__FILE__) . "/../tools/iso-8859-1_str.txt");
	    $this->assertFalse(check_utf8($iso_str));
            $invalid_utf8_str = file_get_contents(dirname(__FILE__) . "/../tools/utf8_str.txt")."\xc3\x28";
	    $this->assertFalse(check_utf8($invalid_utf8_str));
	}
Пример #2
0
function acerta_enc($sinopse)
{
    $sinopse = str_replace('\\', '', str_replace("'", "\\'", mb_convert_encoding($sinopse, 'auto', "HTML-ENTITIES")));
    if (check_utf8($sinopse)) {
        $sinopse = str_replace("'", "\\'", mb_convert_encoding($sinopse, 'auto', "HTML-ENTITIES"));
        //echo "<h4>UTF-8</h4>";
        return $sinopse;
    } else {
        $sinopse = str_replace("'", "\\'", mb_convert_encoding($sinopse, 'utf-8', "HTML-ENTITIES"));
        return $sinopse;
    }
}
Пример #3
0
function test_check_utf8()
{
    if (!check_utf8("auie")) {echo 'échec ligne 4 mod_serveur/test_encoding_functions.php'; return false;}     
    if (!check_utf8("bépowǜdlj")) {echo 'échec ligne 5 mod_serveur/test_encoding_functions.php'; return false;} 
    if (!check_utf8(";œ€âũ")) {echo 'échec ligne 6 mod_serveur/test_encoding_functions.php'; return false;} 
    
	    //$examples = array(
        //    "Valid ASCII" => "a",
        //    "Valid 2 Octet Sequence" => "\xc3\xb1",
        //    "Invalid 2 Octet Sequence" => "\xc3\x28",
        //    "Invalid Sequence Identifier" => "\xa0\xa1",
        //    "Valid 3 Octet Sequence" => "\xe2\x82\xa1",
        //    "Invalid 3 Octet Sequence (in 2nd Octet)" => "\xe2\x28\xa1",
        //    "Invalid 3 Octet Sequence (in 3rd Octet)" => "\xe2\x82\x28",
        //    "Valid 4 Octet Sequence" => "\xf0\x90\x8c\xbc",
        //    "Invalid 4 Octet Sequence (in 2nd Octet)" => "\xf0\x28\x8c\xbc",
        //    "Invalid 4 Octet Sequence (in 3rd Octet)" => "\xf0\x90\x28\xbc",
        //    "Invalid 4 Octet Sequence (in 4th Octet)" => "\xf0\x28\x8c\x28",
        //    "Valid 5 Octet Sequence (but not Unicode!)" => "\xf8\xa1\xa1\xa1\xa1",
        //    "Valid 6 Octet Sequence (but not Unicode!)" => "\xfc\xa1\xa1\xa1\xa1\xa1",
        //);
        
    if (!check_utf8("a")) {echo 'échec ligne 25 mod_serveur/test_encoding_functions.php'; return false;} 
    if (!check_utf8("\xc3\xb1")) {echo 'échec ligne 26 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("\xc3\x28")) {echo 'échec ligne 27 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("\xa0\xa1")) {echo 'échec ligne 28 mod_serveur/test_encoding_functions.php'; return false;} 
    if (!check_utf8("\xe2\x82\xa1")) {echo 'échec ligne 29 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("\xe2\x28\xa1")) {echo 'échec ligne 30 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("\xe2\x82\x28")) {echo 'échec ligne 31 mod_serveur/test_encoding_functions.php'; return false;} 
    if (!check_utf8("\xf0\x90\x8c\xbc")) {echo 'échec ligne 32 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("\xf0\x28\x8c\xbc")) {echo 'échec ligne 33 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("\xf0\x90\x28\xbc")) {echo 'échec ligne 34 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("\xf0\x28\x8c\x28")) {echo 'échec ligne 35 mod_serveur/test_encoding_functions.php'; return false;} 
    if (check_utf8("au à \xc3\x28")) {echo 'échec ligne 35 mod_serveur/test_encoding_functions.php'; return false;}
    //if (!check_utf8("\xfc\xa1\xa1\xa1\xa1\xa1")) {echo 'échec ligne 37 mod_serveur/test_encoding_functions.php'; return false;}
    
    return true;
    
}
Пример #4
0
 /**
  * Defines & retrieves the view and master view. Renders all content within
  * them to the screen.
  *
  * @param string $View
  * @param string $ControllerName
  * @param string $ApplicationFolder
  * @param string $AssetName The name of the asset container that the content should be rendered in.
  * @todo $View, $ControllerName, and $ApplicationFolder need correct variable types and descriptions.
  */
 public function xRender($View = '', $ControllerName = FALSE, $ApplicationFolder = FALSE, $AssetName = 'Content')
 {
     if ($this->_DeliveryType == DELIVERY_TYPE_NONE) {
         return;
     }
     // Handle deprecated StatusMessage values that may have been added by plugins
     $this->InformMessage($this->StatusMessage);
     // If there were uncontrolled errors above the json data, wipe them out
     // before fetching it (otherwise the json will not be properly parsed
     // by javascript).
     if ($this->_DeliveryMethod == DELIVERY_METHOD_JSON) {
         ob_clean();
     }
     // Send headers to the browser
     $this->SendHeaders();
     // Make sure to clear out the content asset collection if this is a syndication request
     if ($this->SyndicationMethod !== SYNDICATION_NONE) {
         $this->Assets['Content'] = '';
     }
     // Define the view
     if (!in_array($this->_DeliveryType, array(DELIVERY_TYPE_BOOL, DELIVERY_TYPE_DATA))) {
         $View = $this->FetchView($View, $ControllerName, $ApplicationFolder);
         // Add the view to the asset container if necessary
         if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
             $this->AddAsset($AssetName, $View, 'Content');
         }
     }
     // Redefine the view as the entire asset contents if necessary
     if ($this->_DeliveryType == DELIVERY_TYPE_ASSET) {
         $View = $this->GetAsset($AssetName);
     } else {
         if ($this->_DeliveryType == DELIVERY_TYPE_BOOL) {
             // Or as a boolean if necessary
             $View = TRUE;
             if (property_exists($this, 'Form') && is_object($this->Form)) {
                 $View = $this->Form->ErrorCount() > 0 ? FALSE : TRUE;
             }
         }
     }
     if ($this->_DeliveryType == DELIVERY_TYPE_MESSAGE && $this->Form) {
         $View = $this->Form->Errors();
     }
     if ($this->_DeliveryType == DELIVERY_TYPE_DATA) {
         $this->RenderData();
     }
     if ($this->_DeliveryMethod == DELIVERY_METHOD_JSON) {
         // Format the view as JSON with some extra information about the
         // success status of the form so that jQuery knows what to do
         // with the result.
         if ($this->_FormSaved === '') {
             // Allow for override
             $this->_FormSaved = property_exists($this, 'Form') && $this->Form->ErrorCount() == 0 ? TRUE : FALSE;
         }
         $this->SetJson('FormSaved', $this->_FormSaved);
         $this->SetJson('DeliveryType', $this->_DeliveryType);
         $this->SetJson('Data', base64_encode($View instanceof Gdn_IModule ? $View->ToString() : $View));
         $this->SetJson('InformMessages', $this->_InformMessages);
         $this->SetJson('ErrorMessages', $this->_ErrorMessages);
         $this->SetJson('RedirectUrl', $this->RedirectUrl);
         // Make sure the database connection is closed before exiting.
         $this->Finalize();
         if (!check_utf8($this->_Json['Data'])) {
             $this->_Json['Data'] = utf8_encode($this->_Json['Data']);
         }
         $Json = json_encode($this->_Json);
         // Check for jsonp call.
         if ($Callback = $this->Request->Get('callback', FALSE)) {
             $Json = $Callback . '(' . $Json . ')';
         }
         $this->_Json['Data'] = $Json;
         exit($this->_Json['Data']);
     } else {
         if (count($this->_InformMessages) > 0 && $this->SyndicationMethod === SYNDICATION_NONE) {
             $this->AddDefinition('InformMessageStack', base64_encode(json_encode($this->_InformMessages)));
         }
         if ($this->RedirectUrl != '' && $this->SyndicationMethod === SYNDICATION_NONE) {
             $this->AddDefinition('RedirectUrl', $this->RedirectUrl);
         }
         // Render
         if ($this->_DeliveryType == DELIVERY_TYPE_BOOL) {
             echo $View ? 'TRUE' : 'FALSE';
         } else {
             if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
                 // Add definitions to the page
                 if ($this->SyndicationMethod === SYNDICATION_NONE) {
                     $this->AddAsset('Foot', $this->DefinitionList());
                 }
                 // Render
                 $this->RenderMaster();
             } else {
                 if ($View instanceof Gdn_IModule) {
                     $View->Render();
                 } else {
                     echo $View;
                 }
             }
         }
     }
 }
Пример #5
0
 /**
  * Defines & retrieves the view and master view. Renders all content within
  * them to the screen.
  *
  * @param string $View
  * @param string $ControllerName
  * @param string $ApplicationFolder
  * @param string $AssetName The name of the asset container that the content should be rendered in.
  * @todo $View, $ControllerName, and $ApplicationFolder need correct variable types and descriptions.
  */
 public function xRender($View = '', $ControllerName = '', $ApplicationFolder = '', $AssetName = 'Content')
 {
     if ($this->_DeliveryType == DELIVERY_TYPE_NONE) {
         return;
     }
     // If there were uncontrolled errors above the json data, wipe them out
     // before fetching it (otherwise the json will not be properly parsed
     // by javascript).
     if ($this->_DeliveryMethod == DELIVERY_METHOD_JSON) {
         ob_clean();
     }
     // Send headers to the browser
     $this->SendHeaders();
     // Make sure to clear out the content asset collection if this is a syndication request
     if ($this->SyndicationMethod !== SYNDICATION_NONE) {
         $this->Assets['Content'] = '';
     }
     // Define the view
     if ($this->_DeliveryType != DELIVERY_TYPE_BOOL) {
         $View = $this->FetchView($View, $ControllerName, $ApplicationFolder);
         // Add the view to the asset container if necessary
         if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
             $this->AddAsset($AssetName, $View, 'Content');
         }
     }
     // Redefine the view as the entire asset contents if necessary
     if ($this->_DeliveryType == DELIVERY_TYPE_ASSET) {
         $View = $this->GetAsset($AssetName);
     } else {
         if ($this->_DeliveryType == DELIVERY_TYPE_BOOL) {
             // Or as a boolean if necessary
             $View = TRUE;
             if (property_exists($this, 'Form') && is_object($this->Form)) {
                 $View = $this->Form->ErrorCount() > 0 ? FALSE : TRUE;
             }
         }
     }
     if ($this->_DeliveryType == DELIVERY_TYPE_MESSAGE && $this->Form) {
         $View = $this->Form->Errors();
     }
     if ($this->_DeliveryMethod == DELIVERY_METHOD_JSON) {
         // Format the view as JSON with some extra information about the
         // success status of the form so that jQuery knows what to do
         // with the result.
         $FormSaved = property_exists($this, 'Form') && $this->Form->ErrorCount() == 0 ? TRUE : FALSE;
         $this->SetJson('FormSaved', $FormSaved);
         $this->SetJson('DeliveryType', $this->_DeliveryType);
         $this->SetJson('Data', base64_encode($View instanceof Gdn_IModule ? $View->ToString() : $View));
         $this->SetJson('StatusMessage', $this->StatusMessage);
         $this->SetJson('RedirectUrl', $this->RedirectUrl);
         // Make sure the database connection is closed before exiting.
         $Database = Gdn::Database();
         $Database->CloseConnection();
         if (!check_utf8($this->_Json['Data'])) {
             $this->_Json['Data'] = utf8_encode($this->_Json['Data']);
         }
         //$Result = json_encode($this->_Json);
         $this->_Json['Data'] = json_encode($this->_Json);
         exit($this->_Json['Data']);
     } else {
         if ($this->StatusMessage != '' && $this->SyndicationMethod === SYNDICATION_NONE) {
             $this->AddAsset($AssetName, '<div class="Messages Information"><ul><li>' . $this->StatusMessage . '</li></ul></div>');
         }
         if ($this->RedirectUrl != '' && $this->SyndicationMethod === SYNDICATION_NONE) {
             $this->AddDefinition('RedirectUrl', $this->RedirectUrl);
         }
         // Render
         if ($this->_DeliveryType == DELIVERY_TYPE_BOOL) {
             echo $View ? 'TRUE' : 'FALSE';
         } else {
             if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
                 // Add definitions to the page
                 if ($this->SyndicationMethod === SYNDICATION_NONE) {
                     $this->AddAsset('Foot', $this->DefinitionList());
                 }
                 // Render
                 $this->RenderMaster();
             } else {
                 if ($View instanceof Gdn_IModule) {
                     $View->Render();
                 } else {
                     echo $View;
                 }
             }
         }
     }
 }
Пример #6
0
 /**
  * Defines & retrieves the view and master view. Renders all content within
  * them to the screen.
  *
  * @param string $View
  * @param string $ControllerName
  * @param string $ApplicationFolder
  * @param string $AssetName The name of the asset container that the content should be rendered in.
  */
 public function xRender($View = '', $ControllerName = false, $ApplicationFolder = false, $AssetName = 'Content')
 {
     // Remove the deliver type and method from the query string so they don't corrupt calls to Url.
     $this->Request->setValueOn(Gdn_Request::INPUT_GET, 'DeliveryType', null);
     $this->Request->setValueOn(Gdn_Request::INPUT_GET, 'DeliveryMethod', null);
     Gdn::pluginManager()->callEventHandlers($this, $this->ClassName, $this->RequestMethod, 'Render');
     if ($this->_DeliveryType == DELIVERY_TYPE_NONE) {
         return;
     }
     // Handle deprecated StatusMessage values that may have been added by plugins
     $this->informMessage($this->StatusMessage);
     // If there were uncontrolled errors above the json data, wipe them out
     // before fetching it (otherwise the json will not be properly parsed
     // by javascript).
     if ($this->_DeliveryMethod == DELIVERY_METHOD_JSON) {
         if (ob_get_level()) {
             ob_clean();
         }
         $this->contentType('application/json; charset=' . c('Garden.Charset', 'utf-8'));
         $this->setHeader('X-Content-Type-Options', 'nosniff');
         // Cross-Origin Resource Sharing (CORS)
         $this->setAccessControl();
     }
     if ($this->_DeliveryMethod == DELIVERY_METHOD_TEXT) {
         $this->contentType('text/plain');
     }
     // Send headers to the browser
     $this->sendHeaders();
     // Make sure to clear out the content asset collection if this is a syndication request
     if ($this->SyndicationMethod !== SYNDICATION_NONE) {
         $this->Assets['Content'] = '';
     }
     // Define the view
     if (!in_array($this->_DeliveryType, array(DELIVERY_TYPE_BOOL, DELIVERY_TYPE_DATA))) {
         $View = $this->fetchView($View, $ControllerName, $ApplicationFolder);
         // Add the view to the asset container if necessary
         if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
             $this->addAsset($AssetName, $View, 'Content');
         }
     }
     // Redefine the view as the entire asset contents if necessary
     if ($this->_DeliveryType == DELIVERY_TYPE_ASSET) {
         $View = $this->getAsset($AssetName);
     } elseif ($this->_DeliveryType == DELIVERY_TYPE_BOOL) {
         // Or as a boolean if necessary
         $View = true;
         if (property_exists($this, 'Form') && is_object($this->Form)) {
             $View = $this->Form->errorCount() > 0 ? false : true;
         }
     }
     if ($this->_DeliveryType == DELIVERY_TYPE_MESSAGE && $this->Form) {
         $View = $this->Form->errors();
     }
     if ($this->_DeliveryType == DELIVERY_TYPE_DATA) {
         $ExitRender = $this->renderData();
         if ($ExitRender) {
             return;
         }
     }
     if ($this->_DeliveryMethod == DELIVERY_METHOD_JSON) {
         // Format the view as JSON with some extra information about the
         // success status of the form so that jQuery knows what to do
         // with the result.
         if ($this->_FormSaved === '') {
             // Allow for override
             $this->_FormSaved = property_exists($this, 'Form') && $this->Form->errorCount() == 0 ? true : false;
         }
         $this->setJson('FormSaved', $this->_FormSaved);
         $this->setJson('DeliveryType', $this->_DeliveryType);
         $this->setJson('Data', base64_encode($View instanceof Gdn_IModule ? $View->toString() : $View));
         $this->setJson('InformMessages', $this->_InformMessages);
         $this->setJson('ErrorMessages', $this->_ErrorMessages);
         $this->setJson('RedirectUrl', $this->RedirectUrl);
         // Make sure the database connection is closed before exiting.
         $this->finalize();
         if (!check_utf8($this->_Json['Data'])) {
             $this->_Json['Data'] = utf8_encode($this->_Json['Data']);
         }
         $Json = json_encode($this->_Json);
         $this->_Json['Data'] = $Json;
         exit($this->_Json['Data']);
     } else {
         if (count($this->_InformMessages) > 0 && $this->SyndicationMethod === SYNDICATION_NONE) {
             $this->addDefinition('InformMessageStack', base64_encode(json_encode($this->_InformMessages)));
         }
         if ($this->RedirectUrl != '' && $this->SyndicationMethod === SYNDICATION_NONE) {
             $this->addDefinition('RedirectUrl', $this->RedirectUrl);
         }
         if ($this->_DeliveryMethod == DELIVERY_METHOD_XHTML && debug()) {
             $this->addModule('TraceModule');
         }
         // Render
         if ($this->_DeliveryType == DELIVERY_TYPE_BOOL) {
             echo $View ? 'TRUE' : 'FALSE';
         } elseif ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
             // Render
             $this->renderMaster();
         } else {
             if ($View instanceof Gdn_IModule) {
                 $View->render();
             } else {
                 echo $View;
             }
         }
     }
 }
Пример #7
0
function is_utf8($string)
{
    return check_utf8($string);
}
Пример #8
0
 if (idn_to_ascii($parts['host']) == '') {
     $parts['host'] = utf8_encode($parts['host']);
 }
 if (isset($_GET['encoding']) && $_GET['encoding'] == 'base64') {
     ob_start('custom_base64');
 }
 if (!isset($parts['scheme'])) {
     header('HTTP/1.0 404 Not Found');
     $img_data['mime'] = 'text/plain';
     echo 'Error 404: Server could parse the ?url= that you were looking for, because it isn\'t a valid url.';
     trigger_error('URL failed, unable to parse. URL: ' . $_GET['url'], E_USER_WARNING);
     die;
 }
 $_GET['url'] = $parts['scheme'] . '://' . idn_to_ascii($parts['host']);
 if (isset($parts['path'])) {
     $parts['path'] = check_utf8($parts['path']) === false ? utf8_encode($parts['path']) : $parts['path'];
     $_GET['url'] .= $parts['path'];
     $_GET['url'] .= isset($parts['query']) ? '?' . $parts['query'] : '';
 }
 $image = create_image($_GET['url']);
 //Change orientation on EXIF-data
 if (isset($img_data['exif'])) {
     if (isset($img_data['exif']['Orientation']) && !empty($img_data['exif']['Orientation'])) {
         switch ($img_data['exif']['Orientation']) {
             case 8:
                 $image = imagerotate($image, 90, 0);
                 //Change source dimensions
                 $temp_w = $img_data[0];
                 $img_data[0] = $img_data[1];
                 $img_data[1] = $temp_w;
                 unset($temp_w);
function utf8($string)
{
    if (!check_utf8($string)) {
        return utf8_encode($string);
    } else {
        return $string;
    }
}
Пример #10
0
    $format = $_GET['format'];
} else {
    $format = 'HTML';
}
$version = isset($_GET['version']) ? $_GET['version'] : 2;
$target = isset($_GET['target']) ? $_GET['target'] : null;
$stsem = isset($_GET['stsem']) ? $_GET['stsem'] : '';
$lva = isset($_GET['lva']) ? $_GET['lva'] : '';
if (isset($_GET["cal"])) {
    // Nicht authentifizierter Zugriff per Codierter UID
    // fuer Abonnierung im Google ueber /webdav/google.php
    $cal = $_GET["cal"];
    $uid = decryptData($cal, LVPLAN_CYPHER_KEY);
    //Wenn der Key manuell geaendert wird koennen Fehlerhaft kodierte Zeichen
    //entstehen und fuehren zu DB fehlern deshalb werden falsch kodierte uids hier aussortiert
    if (!check_utf8($uid)) {
        die('Fehlerhafter Parameter');
    }
    //Pruefen ob dieser Benutzer auch wirklich existiert
    $benutzer = new benutzer();
    if (!$benutzer->load($uid)) {
        die('Ungueltiger Benutzername');
    }
    //Output-Format wird auf ical geaendert
    $target = 'ical';
    $format = 'ical';
} else {
    // UID bestimmen
    $uid = get_uid();
}
// Beginn Ende setzen
Пример #11
0
function toUtf($string)
{
    if (!check_utf8($string)) {
        if (function_exists("iconv")) {
            $string = iconv('cp1252', CHARSET . '//IGNORE', $string);
            #            $string = iconv('ISO-8859-1', CHARSET.'//IGNORE',$string);
        } elseif (function_exists("mb_convert_encoding")) {
            $string = mb_convert_encoding($string, CHARSET);
        } elseif (function_exists("utf8_encode")) {
            $string = utf8_encode($string);
        }
    }
    return $string;
}
Пример #12
0
                    $videoTitle = $row["title"];
                    $videoApprove = $row["aprove"];
                }
            }
        }
    } else {
        echo '<p style="color:red;">Don\'t f**k ass hole !!</p>';
    }
}
$message = '';
if (isset($_POST['title']) && isset($_POST['approve'])) {
    $title = $_POST['title'];
    $approve = $_POST['approve'];
    $postId = $_POST['postid'];
    if (!empty($title) && !empty($approve)) {
        if (!check_utf8($title)) {
            echo 'Not a valid utf8 string';
            exit;
        }
        mysql_query("SET NAMES 'utf8'");
        $query = "UPDATE tblvideo SET title='{$title}', aprove='{$approve}' WHERE `id`= '{$postId}'";
        if ($query_run = mysql_query($query)) {
            $message .= '<p style="color:green;">One video approve successfull.</p>';
        } else {
            $message .= '<p style="color:red;">We could not approve you at this time</p>';
        }
    } else {
        $message .= '<p style="color:red;">Title, approve field requird</p>';
    }
}
// find out how many rows are in the table
Пример #13
0
/**
 * Validate text.
 * @param string $text Text.
 * @return boolean
 * TRUE if text valid and FALSE otherwise.
 */
function posts_check_text($text)
{
    if (!check_utf8($text)) {
        return FALSE;
    } else {
        return TRUE;
    }
}