403Webshell
Server IP : 108.174.197.172  /  Your IP : 216.73.217.162
Web Server : nginx/1.14.1
System : Linux hwsrv-1092325.hostwindsdns.com 4.18.0-553.5.1.el8.x86_64 #1 SMP Tue May 21 05:46:01 UTC 2024 x86_64
User : nginx ( 993)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/aranoinvestmentsgroup.com/public_html/srdb/srdb/srdb-tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/aranoinvestmentsgroup.com/public_html/srdb/srdb/srdb-tests/charset-test.php
<?php

// Connection details
$user = 'root';
$pass = '123';
$host = '127.0.0.1';

// Test data
$original = array(
				'number' => 123,
				'float' => 12.345,
				'string' => 'serialised string',
				'accented' => 'föó ßåŗ',
				'unicode' => '❤ ☀ ☆ ☂ ☻ ♞ ☯',
				'url' => 'http://example.com/'
			);
$serialised = serialize( $original );

// Connect
$x = new PDO( "mysql:host={$host}", $user, $pass );

// Create our schema
$x->query( "CREATE DATABASE IF NOT EXISTS `encode` CHARACTER SET = 'utf8' COLLATE = 'utf8_general_ci';" );
$x->query( 'SET NAMES utf8;' );

// Create a table for each encoding type and stick the encoded array in it.
$charsets = $x->query( 'SELECT CHARACTER_SET_NAME as charset, COLLATION_NAME as collation FROM information_schema.COLLATION_CHARACTER_SET_APPLICABILITY;' );

if ( method_exists( $charsets, 'fetch' ) ) {
	while( $collation = $charsets->fetch() ) {

		$col = $collation[ 'collation' ];
		$charset = $collation[ 'charset' ];
		$tbl_name = $collation[ 'collation' ];

		// Create the table for the collation
		$x->query( "DROP TABLE IF EXISTS `encode`.`{$tbl_name}`" );
		$x->query( "CREATE TABLE  `encode`.`{$tbl_name}` (
			`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
			`number` decimal(10,0) NOT NULL,
			`float` float NOT NULL,
			`string` longtext COLLATE {$col} NOT NULL,
			`accented` longtext COLLATE {$col} NOT NULL,
			`unicode` longtext COLLATE {$col} NOT NULL,
			`url` longtext COLLATE {$col} NOT NULL,
			`serialised` longtext CHARACTER SET {$charset} NOT NULL,
			PRIMARY KEY (`id`)
		  ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET={$charset} COLLATE={$col};" );

		// Set the name space to match to charset
		switch( $charset ) {
			// If I uncomment this utf-16 and utf-32 work, I don't know why though.
			//case 'utf16':
			//case 'utf32':
			//	$x->query( "SET NAMES utf8;" );
			//	break;

			default:
				$x->query( "SET NAMES {$charset};" );
		}

		// Insert our test data
		if ( !$x->query( "INSERT INTO encode.`{$tbl_name}` ( number, float, string, accented, unicode, url, serialised )
							VALUES (
								 {$original['number']},
								 {$original['float']},
								'{$original['string']}',
								'{$original['accented']}',
								'{$original['unicode']}',
								'{$original['url']}',
								'{$serialised}'
							);" ) )
			echo "<pre style=\"color:blue\">Insert Failed: {$col}:{$charset}</pre>";

		// Set names to match table's charset
		$x->query( "SET NAMES {$charset};" );

		// Reclaim what we just dumped into the db and compare
		$q = $x->query( "SELECT serialised FROM encode.{$tbl_name} ORDER BY id DESC LIMIT 1;" );
		if ( method_exists( $q, 'fetch' ) ) {
			while(  $var = $q->fetch( )[0] ) {
				$unserialized = @unserialize( $var );

				if ( !$unserialized || array_diff( $unserialized, $original ) ) {
					echo "<pre style=\"color:red\">Failed: {$col}:{$charset}</pre>";
				}
				else {
					echo "<pre style=\"color:green\">Success: {$col}:{$charset}</pre>";
				}
			}
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit