<?php

				session_start();
				include('database.php');
				DB_connexion(); 
?>		

 <style type="text/css">
   select, ul { height: 100px; overflow: auto; width: 100px; border: 1px solid #000; }
   ul { list-style-type: none; margin: 0; padding: 0; overflow-x: hidden; }
   li { margin: 0; padding: 0; }
   label { display: block; color: WindowText; background-color: Window; margin: 0; padding: 0; width: 100%; }
   label:hover { background-color: Highlight; color: HighlightText; }
  </style>

		<select name="ddl" size=4 multiple>
<option value='blue'>Blue</option>
<option value='green'>Green</option>
<option value='red'>Red</option>
<option value='yellow'>Yelllow</option>
<option value='' selected>Select a Color </option>
<option value='white'>White</option>
</select> 


<h2><code>&lt;input type=&quot;checkbox&quot;&gt;</code></h2>
  <ul>
   <li><label for="chk1"><input type="checkbox" name="chk1" id="chk1">First</label></li>
   <li><label for="chk2"><input type="checkbox" name="chk2" id="chk2">Second</label></li>
   <li><label for="chk3"><input type="checkbox" name="chk3" id="chk3">Third</label></li>
   <li><label for="chk4"><input type="checkbox" name="chk4" id="chk4">Fourth</label></li>
   <li><label for="chk5"><input type="checkbox" name="chk5" id="chk5">Fifth</label></li>
   <li><label for="chk6"><input type="checkbox" name="chk6" id="chk6">Sixth</label></li>
   <li><label for="chk7"><input type="checkbox" name="chk7" id="chk7">Seventh</label></li>
  </ul>

<?php		

				$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
				$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");

				echo $onlyconsonants ."<br>";
				
				$aaaicons = array( ':)'  => '0.gif',
								':(' => '1.gif',
								':P' => '2.gif',
								':D' => '3.gif',
								':S'  => '4.gif',
								':O'  => '5.gif',
								':=)'  => '6.gif',
								':|H' => '7.gif',
								':X'  => '8.gif',
								':-*' => '9.gif');
								
				$icons = array( ':)' , ':(' , ':P' , ':D', ':S', ':O', ':=)', ':|H', ':X',':-*');						

				$str = "Je suis :( mais demain :S vient manger";
				
				for($i = 0; $i < 9; $i++)
				{
					$n = mb_substr_count($str, $icons[$i]);
					if($n != 0)
					{
						
						
						
						$v = $aaaicons[$icons[$i]];
						//echo $v;
						
						//echo "<img src='images/chat/1.gif'";  
				?>
						<img src="images/chat/<?php echo $v ?>"/>
				<?php		
						//echo "<img src='images/chat/'" ."1.gif .">";  
						
						
						//'<img src="images/chat/'.$v.'.gif" alt="'.$smiley.'" width="'.$size.'" height="'.$size.'" />');
						
						//echo '<img src="images/chat/.$v  .'>';
						echo "<br>";
						
					//	$aaa = "<img src='images/chat/' .'0.gif' .'>";
					//	echo $aaa;
						//$bbb = str_replace($icons[$i], $aaa  , $icons[$i]);
						//echo $bbb ."<br>";
					}
					
				}	
				
				$pieces = explode(" ", $pizza);
							
				//$a = "<img src='images/chat/0.gif";			
				//$s = str_replace($icons, $a, $str);			
				//echo $s;	


/*$str_test = "Je suis :( mais demain :S vient manger";

$count = 0;
$find = ":S";
$positions = array();
for($i = 0; $i<strlen($str_test); $i++)
{
     $pos = strpos($str_test, $find, $count);
     if($pos == $count){
           $positions[] = $pos;
     }
     $count++;
}
foreach ($positions as $value) {
    echo '<br/>' .  $value . "<br />";
}
*/
	$str = "Je suis :)mais demain:) vient:)manger puis le chat :S dort sur le lit";
	$icons = array( ':)' , ':(' , ':P' , ':D', ':S', ':O', ':=)', ':|H', ':X',':-*');			
	
	echo $str ."<br>";
	
	for($i = 0; $i < 9; $i++)
	{
		$n = mb_substr_count($str, $icons[$i]);
		if($n != 0)
		{
			for($j = 0; $j < $n; $j++)
			{
					$findme = $icons[$i];
					$l = strlen($findme);
					$pos = strpos($str, $findme);
					echo $pos ."<br>";
					$reste = substr($str, 0, $pos); 
					echo $reste ."<br>";
					$tab[] = $reste;
					$str = substr($str, $pos + $l); 
					echo $str ."<br>";
			}
			// final
			$tab[] = $str;
		}
	}	
	
	print_r($tab);			
	echo "<br>";
	echo "-----------------------";
	echo "<br>";			
	
/*	
			$tab = array();
			
			echo $str ."<br>";	
			$findme = $icons[0];
			$l = strlen($findme);
			
			// premier 
			$pos = strpos($str, $findme);
			echo $pos ."<br>";
			$reste = substr($str, 0, $pos); 
			echo $reste ."<br>";
			$tab[] = $reste;
			$str = substr($str, $pos + $l); 
			echo $str ."<br>";
			
			
			// deuxieme
			$pos = strpos($str, $findme);
			echo $pos ."<br>";
			$reste = substr($str, 0, $pos); 
			echo $reste ."<br>";
			$tab[] = $reste;
			$str = substr($str, $pos + $l); 
			echo $str ."<br>";
			
			//troisieme
			$pos = strpos($str, $findme);
			echo $pos ."<br>";
			$reste = substr($str, 0, $pos); 
			echo $reste ."<br>";
			$tab[] = $reste;
			$str = substr($str, $pos + $l); 
			echo $str ."<br>";
			
			// final
			$tab[] = $str;
					
			print_r($tab);			
			echo "<br>";
			echo "-----------------------";
			echo "<br>";					
									
*/			
							
							
				//$replace = array();
				foreach ($smilies as $smiley => $imgName)
				{
					$size = $sizes[$imgName];
					array_push($replace, '<img src="imgs/'.$imgName.'.gif" alt="'.$smiley.'" width="'.$size.'" height="'.$size.'" />');
				}
				$subject = str_replace(array_keys($smilies), $replace, $subject);		

				$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");
$onlyconsonants = str_replace($vowels, "", "Hello World of PHP");		
				
				
				echo "**************************************";
				$_SESSION['login'] = "plouf";
	
				$sql = "SELECT * FROM user_online WHERE connexion = 'online' ";
				$result = mysql_query($sql);

				while( $data = mysql_fetch_assoc($result) )
				{		
					$users_online[] = $data['login'];
				} 
				
				echo "<pre>";
				
				print_r($users_online);
				
				$n = count($users_online);		
				 
				for($i = 0; $i < $n; $i++)
				{	
						
						$key = array_search($users_online[$i], $_SESSION['etat_connexion']);
						//$longueur = strlen($key);
						
						if($key == 0)
						{
				
							echo $users_online[$i] ."<br>";		
						}
				
				}

				
				echo array_search($users_online[0], $_SESSION['etat_connexion']);
				echo array_search($users_online[1], $_SESSION['etat_connexion']);
				//echo array_search($users_online[2], $_SESSION['etat_connexion']);
				
				$users_online = array ('Francois', 'Michel', 'Nicole', 'Veronique', 'Benoit');
				
				print_r($users_online);
				
				
				
				$msgs=mysql_query('SELECT * FROM tchat ORDER BY id DESC LIMIT 0,50');
				$cpt = 0;
																		
				while($infos = mysql_fetch_array($msgs)) 
				{
					$pieces[] = array();
					$destinataires = $infos["destinataires"];
					$pieces = explode(",", $destinataires);
					print_r($pieces);
					echo "<br>";
				}
				
				
				if($_SESSION['logged'] != 'no' ) 
				{
					echo "plouf";
				}
				else
				{
					echo "no connected";
				}
?>