|
Trouver une ressource
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 du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Robot d'indexation web [ par tony4758 ]
Bonjour, je cherche à créer un mini robot d'indexation web qui releverait les metatags des sites et parcoueraraient les liens. EN sachant qu
PHP / NuSOAP : Xml parsing error [ par pete87150 ]
Bonjour,J'ai créé un service web tout simple pour tester : [WebService(Description="Bienvenue sur le service Web de démo",Namespace="WordGeneration")]
Authentification [ par nicolas66 ]
Salut tlm,je voudrai récupérer des fichiers qui sont sur un site web (pas un ftp) et qui possède une authentification par id et mot de passe. Est-il p
caractere \500 ou @ [ par fofolle ]
dans le code source d'une page phpje tape :echo "\500";je veux faire afficher ce texte sur la page weblorsque je l'execute mon serveur m'affiche sur
echo "\500"; [ par fofolle ]
dans le code source d'une page phpje tape :echo "\500";je veux faire afficher ce texte sur la page weblorsque je l'execute mon serveur m'affiche sur m
site web dynamique [ par las3ad ]
je vais construire un site web dynamique pour une inscription en lignej'utilise PHP et mysqlla base de donnée contenait les champs (num, nom, prenom .
oracle et langages web [ par bruncejs ]
Bonjour à tous et à toutes,Voilà je désire faire un site web accédant à une base de données Oracle. Pour ce faire, il me faut choisir entre quelques l
Creation de pages web sur le tabac [ par ozanyy ]
Coucou, voila, je dois creer un site web sur le tabac et tout ce qui en decoule. J'ai commernce par creer ma page web avec du html, j'ai mis un peu de
lister les fichier pdf d'1rep sur une page web [ par petitepunk ]
slt,je voudrais recupérer ts les fichier pdf situé ds un repertoire appelé "test" pour les afficher sur une page web afin que les utilisateurs puissen
Parsing dynamique [ par kingreboundo ]
Bonjour a vous tous!!!!!!!Je cherche une solution elegante pour me permettre de recuperer les valeurs deja formatter dans ficher ".txt". Le pb c ke le
|
Téléchargements
Logiciels à télécharger sur le même thème :
|