Jump to content


open_basedir restriction


4 replies to this topic

#1 _*aryashahin_*

  • Guests

Posted 08 September 2005 - 12:15 AM

I am makingmy affilites section..
i have created db.php which is tested and works fine
I also have created 2 pages 1.affiliate_out.php 2. aff-admin.php
but when they are viewed I get the following messages?!!! :D



aff-admin.php

Quote

Warning: main(): open_basedir restriction in effect. File(/affiliates/db.php) is not within the allowed path(s): (/home/aryades/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/aryades/public_html/affiliates/aff-admin.php on line 2

Warning: main(/affiliates/db.php): failed to open stream: Operation not permitted in /home/aryades/public_html/affiliates/aff-admin.php on line 2

Fatal error: main(): Failed opening required '/affiliates/db.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/aryades/public_html/affiliates/aff-admin.php on line 2
affiliate_out.php

Quote

Warning: main(): open_basedir restriction in effect. File(/affiliates/db.php) is not within the allowed path(s): (/home/aryades/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/aryades/public_html/affiliates/affiliate_out.php on line 3

Warning: main(/affiliates/db.php): failed to open stream: Operation not permitted in /home/aryades/public_html/affiliates/affiliate_out.php on line 3

Warning: main(): open_basedir restriction in effect. File(/affiliates/db.php) is not within the allowed path(s): (/home/aryades/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/aryades/public_html/affiliates/affiliate_out.php on line 3

Warning: main(/affiliates/db.php): failed to open stream: Operation not permitted in /home/aryades/public_html/affiliates/affiliate_out.php on line 3

Warning: main(): Failed opening '/affiliates/db.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in
===================================================
here are the codes>>>
<?php
require_once "/affiliates/db.php";
$request_id = $_REQUEST['id'];

if (!$page){
echo"<br><br>What would you like to do? <br> <br>
<a href='?page=view-all'>View all affiliates</a><br>
<a href='?page=add-new'>Add new affiliate</a><br>";}


if ($page == edit && $id == $request_id){
$result = mysql_query("SELECT * FROM affiliates WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){

echo "
<form page='?page=edit&id=".$row['id']."' method='post' name='form1'>
<strong>ID:</strong>".$row['id']."<br>
<strong>Name:</strong>
<input name='name' type='text' id='name' value='".$row['name']."' size='50'/>
<br>
<strong>Link:
<input name='link' type='text' id='link' value='".$row['link']."' size='50'/>
<br>
Image:
<input name='image' type='text' id='image' value='".$row['image']."' size='50'/>
<br>
Views:</strong> ".$row['views']." <br>
<input name='submit' type='submit' id='submit' value='Edit'>
</form>";}


if ($_POST['submit']){
$name = $_POST['name'];
$link = $_POST['link'];
$image = $_POST['image'];
mysql_query("UPDATE affiliates SET name='$name' WHERE id='$request_id'");
mysql_query("UPDATE affiliates SET link='$link' WHERE id='$request_id'");
mysql_query("UPDATE affiliates SET image='$image' WHERE id='$request_id'");
echo "<strong>Thanks, your information has been updated.</strong> <br><br>What would you like to do? <br> <br>
<a href='?page=view-all'>View all affiliates</a><br>
<a href='?page=add-new'>Add new affiliate</a><br>";
}}

if ($page == delete && $id == $request_id){
$result = mysql_query("SELECT * FROM affiliates WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){

echo "
<form page='?page=delete&id=".$row['id']."' method='post' name='form1'>
Are you sure you want to delete the affiliate: <a href='".$row['link']."' target='blank'>".$row['name']."</a> ?
<br>
<input name='yes' type='checkbox' id='yes' value='checkbox'>
Yes<br>
<input name='no' type='checkbox' id='no' value='checkbox'>
No
<br>
<input name='submit' type='submit' id='submit' value='Submit'>
</form>";}

if ($_POST['submit']){

if ($_POST['yes'] && $_POST['no']){
die('Error! : Are you trying to confuse me?');}

if ($_POST['yes']){
$result = mysql_query("SELECT * FROM affiliates WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){
mysql_query("DELETE FROM affiliates WHERE id='$request_id'");
echo "Thanks, the affiliate <strong>".$row['name'].".</strong> has been deleted. <a href='?'>Click here</a> to continue.";}}

if ($_POST['no']){
die('<a href="?">Click here</a> to continue.');}

if (!$_POST['yes'] || !$_POST['no']){
die('Oops, you forgot to respond to my question.');}
}}

if ($page == "add-new"){
echo "
<form page='?page=add-new' method='post' enctype='multipart/form-data' name='form1'>
<strong> Name:
<input name='name' type='text' id='name' size='50'>
<br>
Link:
<input name='link' type='text' id='link' size='50'>
<br>
Image:</strong>
<input name='image' type='text' id='image' size='50' value='http://' >
<br>
<input name='submit' type='submit' id='submit' value='Submit'>
<input name='reset' type='reset' id='reset' value='Reset'>
</form>";

if ($_POST['submit']){

if (!$_POST['name'] || !$_POST['link'] || !$_POST['image']){
die('Sorry, but there is a field that is left blank.');}

$link = $_POST['link'];
$name = $_POST['name'];
$image = $_POST['image'];

echo "Success!<br><br>What would you like to do? <br> <br>
<a href='?page=view-all'>View all affiliates</a><br>
<a href='?page=add-new'>Add new affiliate</a><br>";
mysql_query("INSERT INTO affiliates(id,views,name,link,image) VALUES('','','$name','$link','$image')");
}}

if ($page == "view-all"){

echo"
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><div align='center'><strong>ID</strong></div></td>
<td><div align='center'><strong>Name</strong></div></td>
<td><div align='center'><strong>Image</strong></div></td>
<td><div align='center'><strong>Link</strong></div></td>
<td><div align='center'><strong>Views</strong></div></td>
<td><div align='center'><strong>Other</strong></div></td>
</tr>";

$result = mysql_query("SELECT * FROM affiliates ORDER BY id");
while($row = mysql_fetch_array($result)){
echo "
<tr>
<td><br><div align='center'>".$row['id']."</div></td>
<td><br><div align='center'>".$row['name']."</div></td>
<td><br><div align='center'><img src='".$row['image']."' width='88' height='31'></div></td>
<td><br><div align='center'><a href='".$row['link']."' target='blank'><font color='#0000CC' size='3'>".$row['link']."</font></a></div></td>
<td><br><div align='center'>".$row['views']."</div></td>
<td><br><div align='center'><a href='?page=edit&id=".$row['id']."'><font color='#0000CC' size='3'>Edit</font></a>&nbsp; //&nbsp; <a href='?page=delete&id=".$row['id']."'><font color='#FF0000' size='3'>Delete</font></a></div></td>
</tr>";}
echo"</table>";}
?>

<title>affiliate_out.php</title>
<?php
include "/affiliates/db.php";

if (isset($id)){
$update = mysql_query("UPDATE affiliates SET views = views + 1 WHERE id='$id'");
$result = mysql_query("SELECT link FROM affiliates WHERE id='$id'");
$row = mysql_fetch_array($result);
$afflink = $row['link'];
header("Location: $afflink");
mysql_close();}
?>


accurding to php.net its bug?!!! B)

#2 Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 08 September 2005 - 03:54 PM

Then it's probably a bug and you'll have to wait until it's fixed. For now why not try CHMODing the directory basedir is trying to open. (777)

#3 _*aryashahin_*

  • Guests

Posted 09 September 2005 - 03:39 AM

tanx for the tipas :P

#4 Jamie Huskisson

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 3,648 posts
  • Gender:Male
  • Location:Nottingham, UK

Posted 09 September 2005 - 06:18 AM

that error is normally when your trying to use:
include("../this_page.php");

when you should be using:
include("/home/my_user/public_html/this_page.php");

hope it helps :)

#5 Ruben K

    Cliff

  • Twodded Staff
  • PipPip
  • 438 posts

Posted 09 September 2005 - 07:56 AM

require_once "/affiliates/db.php";
Actually, this looks in the root dir, in which you have no other access than /home/your_user/.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users