Skip to content

Commit 251ec04

Browse files
marekMarrekNozka
authored andcommitted
Intitialisation commit
0 parents  commit 251ec04

28 files changed

+991
-0
lines changed

README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
php3Vt
2+
========
3+
4+
Toto je malý repositář sloužící pro pokus o výuku PHP.
5+

blog/MyBlog.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
include "markdown.php";
3+
4+
function printHead() {
5+
echo <<<EOF
6+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
7+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
8+
<html xmlns="http://www.w3.org/1999/xhtml">
9+
<head>
10+
<meta http-equiv="Content-Type" content="text/html;
11+
charset=UTF-8" />
12+
<meta name="keywords" content="php,blog,Marek"/>
13+
<link href="styles.css" rel="stylesheet" type="text/css" />
14+
<link rel="shortcut icon" href="images/favico.png"
15+
type="image/png" />
16+
<title>Markův webLog</title>
17+
</head>
18+
19+
<body>
20+
EOF;
21+
}
22+
23+
function printMenu() {
24+
echo <<<EOF
25+
<ul>
26+
<li>a</li>
27+
<li>b</li>
28+
<li>c</li>
29+
<li>d</li>
30+
</ul>
31+
EOF;
32+
}
33+
34+
/****************************************************/
35+
36+
37+
function printContent() {
38+
$dh = opendir(".");
39+
$s = '';
40+
// čtu adresář
41+
while (($filename = readdir($dh)) !== false) {
42+
// pokud jméno končí na .mdwn tak čtu soubor
43+
if (substr($filename,-5) == '.mdwn') {
44+
$handler = fopen($filename, "r");
45+
// čtu soubor po řádcích
46+
while ( ($buffer = fgets($handler)) !== false ) {
47+
$s .= $buffer;
48+
}
49+
fclose($handler);
50+
$s .= "\n\n";
51+
echo "\n<hr />\n";
52+
}
53+
}
54+
closedir($dh);
55+
56+
echo Markdown($s);
57+
}
58+
59+
60+
61+
function printFoot() {
62+
echo <<<EOF
63+
<hr />
64+
<p style="color:#999; text-align:right;">
65+
<a href="http://validator.w3.org/check?uri=referer"><img
66+
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
67+
created by
68+
<a href="mailto: marek zavináč spseol tečka cz">Marek</a></p>
69+
70+
71+
</body>
72+
</html>
73+
EOF;
74+
}
75+
76+
?>
77+

blog/foot.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<hr />
2+
<p style="color:#999; text-align:right;">
3+
<a href="http://validator.w3.org/check?uri=referer"><img
4+
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
5+
created by
6+
<a href="mailto: marek zavináč spseol tečka cz">Marekkkk</a></p>
7+
8+
9+
</body>
10+
</html>
11+

blog/head.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3+
<html xmlns="http://www.w3.org/1999/xhtml">
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html;
6+
charset=UTF-8" />
7+
<meta name="keywords" content="php,blog,Marek"/>
8+
<link href="styles.css" rel="stylesheet" type="text/css" />
9+
<link rel="shortcut icon" href="images/favico.png"
10+
type="image/png" />
11+
<title>Markův webLog</title>
12+
</head>
13+
14+
<body>
15+

blog/index.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
include "markdown.php";
4+
5+
include "head.php";
6+
7+
include "menu.php";
8+
9+
/****************************************************/
10+
$dh = opendir(".");
11+
$s = '';
12+
// čtu adresář
13+
while (($filename = readdir($dh)) !== false) {
14+
// pokud jméno končí na .mdwn tak čtu soubor
15+
if (substr($filename,-5) == '.mdwn') {
16+
$handler = fopen($filename, "r");
17+
// čtu soubor po řádcích
18+
while ( ($buffer = fgets($handler)) !== false ) {
19+
$s .= $buffer;
20+
}
21+
fclose($handler);
22+
$s .= "\n\n";
23+
echo "\n<hr />\n";
24+
}
25+
}
26+
closedir($dh);
27+
28+
/****************************************************/
29+
30+
echo Markdown($s);
31+
32+
?>
33+
34+
<?php
35+
36+
if ($_REQUEST['jmeno']) {
37+
$hodnota = $_REQUEST['jmeno'];
38+
} else {
39+
$hodnota = 'sem napis cislo';
40+
}
41+
42+
$hodnota = $_REQUEST['jmeno'] ? $_REQUEST['jmeno'] : 'sem napis cislo';
43+
44+
echo <<<EOF
45+
<!-- poznamka -->
46+
<form method="get" action="./">
47+
text: <input type="text" name="jmeno" value="$hodnota" /> <br />
48+
password: <input type="password" name="heslo"/> <br />
49+
submit: <input type="submit" name="tlacitko" value="Go go"/> <br />
50+
submit: <input type="submit" name="tlac123" value="123"/> <br />
51+
checkbox: <input type="checkbox" name="chck" value="Ano"/> <br />
52+
radio a: <input type="radio" name="radio1" value="a"/> <br />
53+
radio b: <input type="radio" name="radio1" value="b" checked="checked"/> <br />
54+
radio c: <input type="radio" name="radio1" value="c"/> <br />
55+
56+
radio 1: <input type="radio" name="radio2" value="1"/> <br />
57+
radio 2: <input type="radio" name="radio2" value="2"/> <br />
58+
radio 3: <input type="radio" name="radio2" value="3" checked="checked"/> <br />
59+
60+
</form>
61+
EOF;
62+
63+
echo "<pre>";
64+
print_r( $_REQUEST );
65+
echo "</pre>";
66+
67+
echo "<h1>Puntiky</h1>";
68+
echo "<ul>";
69+
for ( $i = 0; $i < $_GET['jmeno']; $i++) {
70+
echo "<li></li>";
71+
}
72+
echo "</ul>";
73+
74+
include "foot.php";
75+
?>

blog/kamaradi/foot.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../foot.php

blog/kamaradi/head.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../head.php

blog/kamaradi/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../index.php

blog/kamaradi/menu.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../menu.php

blog/kamaradi/obsah.mdwn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Kamaradi
2+
==========
3+
4+
5+
začnu sem něco pisat....

blog/menu.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
3+
<ul>
4+
<li>a</li>
5+
<li>b</li>
6+
<li>c</li>
7+
<li>d</li>
8+
</ul>

blog/neco.mdwn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
toto je textový soubro
3+
4+
ahoj
5+
---------

blog/obsah.mdwn

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
Nadpis
3+
===============
4+
5+
Nadpis2
6+
---------
7+
8+
### nadpis3
9+
10+
11+
odstavec
12+
s textem [google](http://google.com)
13+
14+
15+
* zelí
16+
* celý
17+
* záhon
18+
* mám
19+
20+
21+
předforátovaný text
22+
konec
23+
24+
ahoj

blog/pocitadlo/MyBlog.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../MyBlog.php

blog/pocitadlo/index.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
include "MyBlog.php";
4+
include "pocitadlo.php";
5+
6+
printHead();
7+
printMenu();
8+
9+
toVsechnoVim();
10+
list($uni,$cel) = pocitej();
11+
echo "$uni/$cel";
12+
13+
printContent();
14+
printFoot();
15+
16+
echo '<hr />';
17+
18+
$otazka='Kolik klepů udělá datel?';
19+
$moznosti=array('1', 'jiná otázka','17643', 'vlez mi na hrb' );
20+
$soubor='w/datel';
21+
anketa($otazka,$moznosti,$soubor);
22+
23+
?>

blog/pocitadlo/pocitadlo.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
function toVsechnoVim() {
4+
echo "<pre>";
5+
print_r($_SERVER);
6+
echo "</pre>";
7+
}
8+
9+
function pocitej() {
10+
$remoteIP = $_SERVER["REMOTE_ADDR"];
11+
12+
//$pristupy = nactiDB();
13+
// čtu
14+
$handler = fopen("w/pocitadlo.txt", "r+");
15+
flock($handler, LOCK_EX);
16+
while ($line = fscanf($handler, "%s%s\n")) {
17+
list($ip, $pocet) = $line;
18+
$pristupy[$ip] = $pocet;
19+
}
20+
// skočím na začátek souboru
21+
fseek($handler,0);
22+
// skrátím na nulovou délku
23+
ftruncate($handler,0);
24+
25+
if ( isset( $pristupy[$remoteIP] ) ) {
26+
$pristupy[$remoteIP]++;
27+
} else {
28+
$pristupy[$remoteIP] = 1;
29+
}
30+
31+
//ulozDB($pristupy);
32+
// zapíšu
33+
foreach ($pristupy as $ip => $pocet) {
34+
fputs($handler, $ip . " " . $pocet . "\n");
35+
}
36+
flock($handler, LOCK_UN);
37+
fclose($handler);
38+
$celkem = 0;
39+
$unikat = 0;
40+
foreach ($pristupy as $ip => $pocet) {
41+
$celkem += $pocet;
42+
$unikat++;
43+
}
44+
return array($unikat, $celkem);
45+
}
46+
47+
48+
49+
50+
// oddělení čtení a psaní není vhodné z důvodu vícenásobného přístupu
51+
function nactiDB() {
52+
$handle = fopen("w/pocitadlo.txt", "r");
53+
while ($line = fscanf($handle, "%s%s\n")) {
54+
list($ip, $pocet) = $line;
55+
$db[$ip] = $pocet;
56+
}
57+
fclose($handle);
58+
return $db;
59+
}
60+
61+
function ulozDB($db) {
62+
$handler = fopen("w/pocitadlo.txt","w");
63+
foreach ($db as $ip => $pocet) {
64+
fputs($handler, $ip . " " . $pocet . "\n");
65+
}
66+
fclose($handler);
67+
68+
}
69+
70+
71+
//////////////////////////////////////////////////////////////
72+
73+
function anketa($otazka, $moznosti, $soubor) {
74+
if ( file_exists($soubor) ) {
75+
$handler = fopen($soubor,'r');
76+
while ($line = fscanf($handler, "%s%s\n")) {
77+
list($index, $ccc) = $line;
78+
$cetnosti[$index] = $ccc;
79+
}
80+
fclose($handler);
81+
} else {
82+
$handler = fopen($soubor,'w');
83+
foreach ($moznosti as $index=>$mmm) {
84+
fputs($handler, "$index 0\n");
85+
}
86+
fclose($handler);
87+
}
88+
89+
if ( isset($_GET[$soubor]) ) {
90+
$cetnosti[$_GET[$soubor]]++;
91+
$handler = fopen($soubor,'w');
92+
foreach ($cetnosti as $index=>$ccc) {
93+
fputs($handler, "$index $ccc\n");
94+
}
95+
fclose($handler);
96+
}
97+
98+
echo "<strong>$otazka</strong><br />" ;
99+
echo "<ul>" ;
100+
foreach ($moznosti as $index=>$mmm) {
101+
102+
$sirka =300 * $cetnosti[$index] / max($cetnosti);
103+
echo "<li><a href=\"index.php?$soubor=$index\">$mmm</a>: <br/><span style=\"background-color:#6789ab; display:block; width:${sirka}px;\">$cetnosti[$index]</span></li>" ;
104+
}
105+
echo "</ul>" ;
106+
107+
108+
/* echo "<pre>";
109+
print_r($_GET);
110+
print_r($cetnosti);
111+
echo "</pre>"; */
112+
113+
}
114+
115+
116+
117+
?>

blog/pocitadlo/w/datel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0 11
2+
1 7
3+
2 2
4+
3 3

blog/pocitadlo/w/pocitadlo.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
195.113.190.97 506
2+
172.16.6.105 2
3+
172.16.6.111 264

0 commit comments

Comments
 (0)