|
begin process at 2008 07 21 02:35:18
Derniers logiciels
|
Trouver une ressource (Nouvelle version du moteur, plus rapide & pertinent, essayez le !)
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
ROBOT POUR LE WEB : SUDOKU VERSION IMPRIMABLE (THÈME DE LINUX MAG)
Information sur la source
Description
Cette source visite 12 pages de chez http://www.websudoku.com, et affiche 12 sudoku par page pour pouvoir imprimer en ayant une taille corecte, mais garder quand même plusieurs sudoku par pages (sur le site de websudoku, on ne peut en imprimer qu'un par page...) Dans le magazine linux-mag, ils parlaient de robots pour le web, ils expliquaient comment en faire, en perl et en php, j'ai cherché une application, j'ai trouvé... ça sert principalement à ne pas avoir besoin de mettre en forme ses sudokus pour les imprimer...
Source
- <html>
- <head>
- <style>
- .sudoku{
- display: table-cell;
- width:30%;
- height:20%;
- }
- .sudoku table{
- text-align:center;
- empty-cells: show;
- border-collapse: collapse;
- }
- .sudoku table tr td{
- width:25px;
- height:25px;
- border:1px solid #DDD;
- }
- .sudoku table tr td.left{
- border-left:1px solid #000 !important;
- }
- .sudoku table tr td.lefttop{
- border-left:1px solid #000 !important;
- border-top:1px solid #000 !important;
- }
- .sudoku table tr td.leftbottom{
- border-left:1px solid #000 !important;
- border-bottom:1px solid #000 !important;
- }
- .sudoku table tr td.right{
- border-right:1px solid #000 !important;
- }
- .sudoku table tr td.righttop{
- border-right:1px solid #000 !important;
- border-top:1px solid #000 !important;
- }
- .sudoku table tr td.rightbottom{
- border-right:1px solid #000 !important;
- border-bottom:1px solid #000 !important;
- }
- .sudoku table tr td.top{
- border-top:1px solid #000 !important;
- }
- .sudoku table tr td.bottom{
- border-bottom:1px solid #000 !important;
- }
- </style>
- </head>
- <body>
- <?php
- function echolevel($level){
- if ($level=='1')
- echo 'facile';
- else if ($level=='2')
- echo 'moyen';
- else if ($level=='3')
- echo 'difficile';
- else
- echo 'démoniaque';
- }
- function aff_sudoku($level){
- echo '<div class="sudoku">';
- /*
- echolevel($level);
- */
- echo '<table>';
- $a1=file_get_contents('http://show.websudoku.com/?level='.$level);
- $a=explode('<TABLE CELLSPACING=0 CLASS=t>', $a1);
- $a=explode('</TABLE>',$a[1]);
- $a=explode('</TR>',$a[0]);
- foreach ($a as $y=>$b){
- if ($y<9){
- echo '<tr>';
- $c=explode('<TD', $b);
- foreach ($c as $x1=>$d){
- if ($x1>0){
- $x=$x1-1;
- if (substr_count('CLASS=s0', $d))
- $v='';
- else{
- preg_match('/VALUE="([1-9])"/', $d, $v);
- $v=$v[1];
- }
- if ($x%3==0)
- $style='left';
- else if ($x%3==2)
- $style='right';
- else
- $style='';
- if ($y%3==0)
- $style.='top';
- else if ($y%3==2)
- $style.='bottom';
- echo '<td class="',$style,'">',$v,'</td>';
- }
- }
- echo '</tr>';
- }
- }
- preg_match('/Puzzle ([0-9,]+) /', $a1, $num);
- echo '</table>
- Sudoku n° : ',$num[1], '</div>';
- }
- $level=isset($_GET['level'])?$_GET['level']:'4';
- echo '<table>
- <tr><th colspan="3">';
- echolevel($level);
- echo '</th></tr>';
- for ($x=0;$x<4;$x++){
- echo '<tr>';
- for ($y=0;$y<3;$y++){
- echo '<td>';
- aff_sudoku($level);
- echo '</td>';
- }
- echo '</tr>';
- }
- echo '</table>';
-
- ?>
- <div id="noprint">
- <a href="?level=1">facile</a> |
- <a href="?level=2">moyen</a> |
- <a href="?level=3">difficile</a> |
- <a href="?level=4">démoniaque</a> |
- <a href="#" onclick="document.getElementById('noprint').style.display='none';">imprimer</a>
- </div>
- </body>
- </html>
<html>
<head>
<style>
.sudoku{
display: table-cell;
width:30%;
height:20%;
}
.sudoku table{
text-align:center;
empty-cells: show;
border-collapse: collapse;
}
.sudoku table tr td{
width:25px;
height:25px;
border:1px solid #DDD;
}
.sudoku table tr td.left{
border-left:1px solid #000 !important;
}
.sudoku table tr td.lefttop{
border-left:1px solid #000 !important;
border-top:1px solid #000 !important;
}
.sudoku table tr td.leftbottom{
border-left:1px solid #000 !important;
border-bottom:1px solid #000 !important;
}
.sudoku table tr td.right{
border-right:1px solid #000 !important;
}
.sudoku table tr td.righttop{
border-right:1px solid #000 !important;
border-top:1px solid #000 !important;
}
.sudoku table tr td.rightbottom{
border-right:1px solid #000 !important;
border-bottom:1px solid #000 !important;
}
.sudoku table tr td.top{
border-top:1px solid #000 !important;
}
.sudoku table tr td.bottom{
border-bottom:1px solid #000 !important;
}
</style>
</head>
<body>
<?php
function echolevel($level){
if ($level=='1')
echo 'facile';
else if ($level=='2')
echo 'moyen';
else if ($level=='3')
echo 'difficile';
else
echo 'démoniaque';
}
function aff_sudoku($level){
echo '<div class="sudoku">';
/*
echolevel($level);
*/
echo '<table>';
$a1=file_get_contents('http://show.websudoku.com/?level='.$level);
$a=explode('<TABLE CELLSPACING=0 CLASS=t>', $a1);
$a=explode('</TABLE>',$a[1]);
$a=explode('</TR>',$a[0]);
foreach ($a as $y=>$b){
if ($y<9){
echo '<tr>';
$c=explode('<TD', $b);
foreach ($c as $x1=>$d){
if ($x1>0){
$x=$x1-1;
if (substr_count('CLASS=s0', $d))
$v='';
else{
preg_match('/VALUE="([1-9])"/', $d, $v);
$v=$v[1];
}
if ($x%3==0)
$style='left';
else if ($x%3==2)
$style='right';
else
$style='';
if ($y%3==0)
$style.='top';
else if ($y%3==2)
$style.='bottom';
echo '<td class="',$style,'">',$v,'</td>';
}
}
echo '</tr>';
}
}
preg_match('/Puzzle ([0-9,]+) /', $a1, $num);
echo '</table>
Sudoku n° : ',$num[1], '</div>';
}
$level=isset($_GET['level'])?$_GET['level']:'4';
echo '<table>
<tr><th colspan="3">';
echolevel($level);
echo '</th></tr>';
for ($x=0;$x<4;$x++){
echo '<tr>';
for ($y=0;$y<3;$y++){
echo '<td>';
aff_sudoku($level);
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
?>
<div id="noprint">
<a href="?level=1">facile</a> |
<a href="?level=2">moyen</a> |
<a href="?level=3">difficile</a> |
<a href="?level=4">démoniaque</a> |
<a href="#" onclick="document.getElementById('noprint').style.display='none';">imprimer</a>
</div>
</body>
</html>
Conclusion
un aperçu :
http://coucou747.hopto.org/php_apercus/sudoku_print.php
Historique
- 20 décembre 2005 21:41:50 :
- petite mise à jour : amélioration des CSS, niveau affiché une seule fois, un javascript pour cacher les liens.
Sources de la même categorie
Commentaires
Discussions en rapport avec ce code source
|
Téléchargements
Logiciels à télécharger sur le même thème :
|
|