Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

PHP - Finger PHP Simple Client

// Finger Download Information

<?php
	// Client di Finger

	$fp = fsockopen('kernel.org', 79); // Si collega al seguente server nella porta 79
	
	fputs($fp, '@kernel.org\n'); // Manda una richiesta
	
	echo '<table border=\'0\' cellspacing=\'1\' cellpadding=\'1\' bgcolor=\'black\'>';
	
	while( !feof($fp) )
	{	
		$text = fgets($fp, 128); // Ritorna una risposta

		if(trim($text) != '')
		{
			echo '<tr bgcolor=\'white\'>';
			echo '<td>';
			echo '<font face=\'Arial\' size=\'-2\'>' . trim($text) . '</font>';
			echo '</td>';
			echo '</tr>';
		}
	}
	
	echo '</table>';
	
	fclose($fp);
?>

PHP - InversoMoltiplicativo

// Calcolo degli inversi moltiplicativi

<html>
	<head>
		<title>Calcolo degli inversi moltiplicativi</title>
	</head>

	<body>
		<center>
		<b>Cancolo dell'Inverso Moltiplicativo</b>
		<br><hr><br>
		<table border="1" align="center">
		<?php
			for($i=0; $i<26; $i++)
			{
		?>
			<tr>
		<?php
				for($j=0; $j<26; $j++)
				{
					if($i==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $j . "</td>";
					else
					if($j==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $i . "</td>";
					else
					{
						echo "<td align=\"center\">" . $i*$j . "</td>";
						$matrice[$i-1][$j-1] = $i*$j;
					}
				}
		?>
			</tr>
		<?php
			}

			for($i=0; $i<25; $i++)
				for($j=0; $j<25; $j++)
					$matrice[$i][$j] = $matrice[$i][$j]%26;
		?>
		</table>
		<br><hr>
		<b>Tabella dell'Inverso Moltiplicativo</b>
		<br><hr><br>
		<table border="1" align="center">
		<?php
			for($i=0; $i<26; $i++)
			{
				echo "<tr>";
				
				for($j=0; $j<26; $j++)
				{
					if($i==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $j . "</td>";
					else
					if($j==0) echo "<td bgcolor=\"yellow\" align=\"center\">" . $i . "</td>";
					else
					{
						echo "<td align=\"center\" " . (($matrice[$i-1][$j-1] == 1)?"bgcolor=\"red\"":"") . "\">" . $matrice[$i-1][$j-1] . "</td>";
						
						if($matrice[$i-1][$j-1] == 1)
							$np[] = $i;
					}
				}

				echo "</tr>";
			}
		?>
		</table>
		<br>
		<i><b>I numeri primi con 26 sono:
		<?php
			for($i=0; $i<count($np); $i++)
				echo $np[$i] . " ";
		?>
		</b></i>
		<br><br>
		Si prendono le coppie di numeri che contengono il numero 1 al loro interno, esempio (1,1), (3,9)......
		</center>
	</body>
</html>
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS