403 error bij het gebruik van PHP
"Forbidden
You don't have permission to access /MySQLBoek/install/method="get" on this server.
Apache/1.3.33 Server at localhost Port 80"
Foutmeldingen heb ik hier ingekort tot "Error."
Ik heb geprobeerd om de WWW map zoveel mogelijk rechten toe te kennen, zowel in Windows als in het Apache configuratie bestand. Veiligheid s niet het grootste probleem omdat de server alleen op Localhost draait.
Een vorbeeld van een script wat deze melding veroorzaakt is het volgende.
===================================================
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
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
<?
mysql_connect("xxx", "xxx", "xxxx") or die // gecorrigeerd in het echte script.
("<h3>Error .</h3>");
$all_dbs = array ("guestbook2k", "catalog", "discussion","netsloth", "survey", "tracking");
if(isset($submit))
{
$to_install = array();
if(isset($passed_dbs) && is_array($passed_dbs) && isset($install_all))
{
echo " error etc..";
exit;
} elseif (isset($passed_dbs) && is_array($passed_dbs))
{
$to_install = $passed_dbs;
} elseif (isset($install_all))
{
$to_install = $all_dbs;
}
else
{
echo "error etc.";
exit;
}
// $path = $DOCUMENT_ROOT . "/book/install/";
foreach($to_install as $dbname)
{
//create and slect database
mysql_query("drop database if exists $dbname") or die
(mysql_error() . "Could not drop database $dbname ");
mysql_query("create database $dbname") or die
(mysql_error() . "Could not create database $dbname ");
mysql_select_db($dbname);
//files will come in the form dbname.dump
//$file_to_parse = $path . $dbname . ".dump";
$file_to_parse = $dbname . ".dump";
if (!file_exists($file_to_parse))
{
echo "error...";
exit;
}
if (!$fp = fopen($file_to_parse, "r"))
{
echo "error....";
exit;
}
$contents = fread($fp, filesize ($file_to_parse));
fclose($fp);
//parse out drop, create, and insert statments
preg_match_all("/(DROP TABLE.*?);/s", $contents, $drop_statements);
preg_match_all("/(CRE.*?);/s", $contents, $create_statements);
preg_match_all("/(INSER.*?);[\n\r]/s", $contents, $insert_statements);
foreach($drop_statements[1] as $query)
{
mysql_query($query) or die
(mysql_error(). " drop table failed: $query.");
}
foreach($create_statements[1] as $query)
{
mysql_query($query) or die
(mysql_error(). " create table failed: $query.");
}
foreach($insert_statements[1] as $query)
{
mysql_query($query) or die
(mysql_error() . "insert failed: $query.");
}
echo "database \"$dbname\" successfully created.<br>\n";
}
}
else
{
?>
mysql_connect("xxx", "xxx", "xxxx") or die // gecorrigeerd in het echte script.
("<h3>Error .</h3>");
$all_dbs = array ("guestbook2k", "catalog", "discussion","netsloth", "survey", "tracking");
if(isset($submit))
{
$to_install = array();
if(isset($passed_dbs) && is_array($passed_dbs) && isset($install_all))
{
echo " error etc..";
exit;
} elseif (isset($passed_dbs) && is_array($passed_dbs))
{
$to_install = $passed_dbs;
} elseif (isset($install_all))
{
$to_install = $all_dbs;
}
else
{
echo "error etc.";
exit;
}
// $path = $DOCUMENT_ROOT . "/book/install/";
foreach($to_install as $dbname)
{
//create and slect database
mysql_query("drop database if exists $dbname") or die
(mysql_error() . "Could not drop database $dbname ");
mysql_query("create database $dbname") or die
(mysql_error() . "Could not create database $dbname ");
mysql_select_db($dbname);
//files will come in the form dbname.dump
//$file_to_parse = $path . $dbname . ".dump";
$file_to_parse = $dbname . ".dump";
if (!file_exists($file_to_parse))
{
echo "error...";
exit;
}
if (!$fp = fopen($file_to_parse, "r"))
{
echo "error....";
exit;
}
$contents = fread($fp, filesize ($file_to_parse));
fclose($fp);
//parse out drop, create, and insert statments
preg_match_all("/(DROP TABLE.*?);/s", $contents, $drop_statements);
preg_match_all("/(CRE.*?);/s", $contents, $create_statements);
preg_match_all("/(INSER.*?);[\n\r]/s", $contents, $insert_statements);
foreach($drop_statements[1] as $query)
{
mysql_query($query) or die
(mysql_error(). " drop table failed: $query.");
}
foreach($create_statements[1] as $query)
{
mysql_query($query) or die
(mysql_error(). " create table failed: $query.");
}
foreach($insert_statements[1] as $query)
{
mysql_query($query) or die
(mysql_error() . "insert failed: $query.");
}
echo "database \"$dbname\" successfully created.<br>\n";
}
}
else
{
?>
<p>Databases to install:</p>
<form action = method="get">
Code (php)
<br>
<input type="checkbox" name="install_all" value="yes">Install All<br>
<input type="submit" name="submit" value="Submit">
</form>
=============================================================
Er zijn nog geen reacties op dit bericht.