[OPGELOST] if then en scripten includen
Dit is een vervolg op mijn oude bericht if/then. Daarin wilde ik een 2 talige website. Via TheSan heb ik een mooi script welke goed werkt!
De code is een stuk minder overzichtelijk maar in 1 pag. heb je wel 2 talen .. helemaal toppie!
Ik zit alleen met een klein probleem
Ik heb een php scriptje gemaakt welke ik in een apart bestand geplaatst heb. Dit is een directory listing scriptje. Ik heb dit dirlist.php genoemd.
Ik heb nu een include toegevoegd welke deze php pagina oproept, maar dat werkt niet. Ik krijg dat de inhoud van het script te zien ipv dat hij heb uitvoerd.
Ik heb daarom dan een include of require geprobeerd, maar dat geeft hetzelfde probleem.
Ik hoop dat het wel mogelijk is een extern php script aan te roepen en te laten uitvoeren?
Dit is de pagina http://www.dejavureportage.nl/v2/new.php
Stef
Gewijzigd op 01/01/1970 01:00:00 door Stef Segers
Laat eens zien hoe je het bestand nu include?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>DejaVu Reportage</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="/includes/fotofadein.js"></script>
</head>
<body>
<?php
$arrStr = explode("/", $_SERVER['SCRIPT_NAME'] );
$arrStr = array_reverse($arrStr );
?>
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
$talen = array('NL' => array('titel' => '<div id="tekst_rechts"><h2 align="right">Nieuwe foto´s</h2>',
'menu' => 'menu_nl.php'),
'ENG' => array('titel' => '<div id="tekst_rechts"><h2 align="right">New pictures</h2>',
'menu' => 'menu_eng.php'),
);
if(isset($_GET['LANG']) and isset($talen[$_GET['LANG']]))
{
$language = $_GET['LANG'];
}
else
{
$language = 'NL';
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>DejaVu Reportage</title>
<link href="/css/dejastyle2.css" rel="stylesheet" type="text/css" media="screen" />';
include('../includes/metatags.inc');
echo '<script type="text/javascript" src="/includes/fotofadein.js"></script>
</head>
<body>
<div id="distance"></div>
<div id="container">
<div id="language"><a href="';
echo $arrStr[0];
echo '?LANG=NL">nederlands</a> / <a href="';
echo $arrStr[0];
echo '?LANG=ENG">english</a></div>
<div align="center"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="content_cell">';
echo $talen[$language]['titel'];
require "dirlisting.php";
echo '</div><div id="NEW">';
if(!isset($_GET["naam"])){;
echo '<img src="/images/intro_new.jpg" width="400" height="300" />';
} else {;
echo '<iframe style="border: medium none ; background-color:FFFFFF;" src="/NEW/<?php PRINT $_GET["naam"]; ?>/iframe.html" title="Slideshow" frameborder="0" height="370" width="500" scrolling="no"></iframe>';
};
echo '</div>';
include($talen[$language]['menu']);
echo '</div>
</td>
</tr>';
include('footer.inc');
echo '
</table>
</div>
</body>
</html>
';
?>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>DejaVu Reportage</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="/includes/fotofadein.js"></script>
</head>
<body>
<?php
$arrStr = explode("/", $_SERVER['SCRIPT_NAME'] );
$arrStr = array_reverse($arrStr );
?>
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
$talen = array('NL' => array('titel' => '<div id="tekst_rechts"><h2 align="right">Nieuwe foto´s</h2>',
'menu' => 'menu_nl.php'),
'ENG' => array('titel' => '<div id="tekst_rechts"><h2 align="right">New pictures</h2>',
'menu' => 'menu_eng.php'),
);
if(isset($_GET['LANG']) and isset($talen[$_GET['LANG']]))
{
$language = $_GET['LANG'];
}
else
{
$language = 'NL';
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>DejaVu Reportage</title>
<link href="/css/dejastyle2.css" rel="stylesheet" type="text/css" media="screen" />';
include('../includes/metatags.inc');
echo '<script type="text/javascript" src="/includes/fotofadein.js"></script>
</head>
<body>
<div id="distance"></div>
<div id="container">
<div id="language"><a href="';
echo $arrStr[0];
echo '?LANG=NL">nederlands</a> / <a href="';
echo $arrStr[0];
echo '?LANG=ENG">english</a></div>
<div align="center"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="content_cell">';
echo $talen[$language]['titel'];
require "dirlisting.php";
echo '</div><div id="NEW">';
if(!isset($_GET["naam"])){;
echo '<img src="/images/intro_new.jpg" width="400" height="300" />';
} else {;
echo '<iframe style="border: medium none ; background-color:FFFFFF;" src="/NEW/<?php PRINT $_GET["naam"]; ?>/iframe.html" title="Slideshow" frameborder="0" height="370" width="500" scrolling="no"></iframe>';
};
echo '</div>';
include($talen[$language]['menu']);
echo '</div>
</td>
</tr>';
include('footer.inc');
echo '
</table>
</div>
</body>
</html>
';
?>
En hier de dirlisting.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function getFiles($path) {
//Function takes a path, and returns a numerically indexed array of associative arrays containing file information,
//sorted by the file name (case insensitive). If two files are identical when compared without case, they will sort
//relative to each other in the order presented by readdir()
$files = array();
$fileNames = array();
$i = 0;
if (is_dir($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
if ($file == "." || $file == "..") continue;
$fullpath = $path . "/" . $file;
$fkey = strtolower($file);
while (array_key_exists($fkey,$fileNames)) $fkey .= " ";
$a = stat($fullpath);
$files[$fkey]['size'] = $a['size'];
if ($a['size'] == 0) $files[$fkey]['sizetext'] = "-";
else if ($a['size'] > 1024) $files[$fkey]['sizetext'] = (ceil($a['size']/1024*100)/100) . " K";
else if ($a['size'] > 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/(1024*1024)*100)/100) . " Mb";
else $files[$fkey]['sizetext'] = $a['size'] . " bytes";
$files[$fkey]['name'] = $file;
$files[$fkey]['type'] = filetype($fullpath);
$fileNames[$i++] = $fkey;
}
closedir($dh);
} else die ("Cannot open directory: $path");
} else die ("Path is not a directory: $path");
sort($fileNames,SORT_STRING);
$sortedFiles = array();
$i = 0;
foreach($fileNames as $f) $sortedFiles[$i++] = $files[$f];
return $sortedFiles;
}
$files = getFiles("./NEW");
foreach ($files as $file) print "<a href=\"new.php?naam=$file[name]\">$file[name]</a><br>\n";
//Function takes a path, and returns a numerically indexed array of associative arrays containing file information,
//sorted by the file name (case insensitive). If two files are identical when compared without case, they will sort
//relative to each other in the order presented by readdir()
$files = array();
$fileNames = array();
$i = 0;
if (is_dir($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
if ($file == "." || $file == "..") continue;
$fullpath = $path . "/" . $file;
$fkey = strtolower($file);
while (array_key_exists($fkey,$fileNames)) $fkey .= " ";
$a = stat($fullpath);
$files[$fkey]['size'] = $a['size'];
if ($a['size'] == 0) $files[$fkey]['sizetext'] = "-";
else if ($a['size'] > 1024) $files[$fkey]['sizetext'] = (ceil($a['size']/1024*100)/100) . " K";
else if ($a['size'] > 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/(1024*1024)*100)/100) . " Mb";
else $files[$fkey]['sizetext'] = $a['size'] . " bytes";
$files[$fkey]['name'] = $file;
$files[$fkey]['type'] = filetype($fullpath);
$fileNames[$i++] = $fkey;
}
closedir($dh);
} else die ("Cannot open directory: $path");
} else die ("Path is not a directory: $path");
sort($fileNames,SORT_STRING);
$sortedFiles = array();
$i = 0;
foreach($fileNames as $f) $sortedFiles[$i++] = $files[$f];
return $sortedFiles;
}
$files = getFiles("./NEW");
foreach ($files as $file) print "<a href=\"new.php?naam=$file[name]\">$file[name]</a><br>\n";
Ik heb in de dirlisting vergeten de te plaatsen
Ik dacht dat dat niet nodig was...
Alles werkt nu !!!