dejanosi
03-18-2008, 12:02 PM
hi i'm new here and i have a big problem with my script please help
when i try to submit picture show me this error
Warning: move_uploaded_file(./content/images/SJV_Ugly longhairy dude took a shower.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/ivanco4/public_html/index.php on line 245
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpd2Fbay' to './content/images/SJV_Ugly longhairy dude took a shower.jpg' in /home/ivanco4/public_html/index.php on line 245
Warning: getimagesize(./content/images/SJV_Ugly longhairy dude took a shower.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/ivanco4/public_html/index.php on line 274
Warning: Cannot modify header information - headers already sent by (output started at /home/ivanco4/public_html/index.php:245) in /home/ivanco4/public_html/index.php on line 316
here is the script can you help me please
}
}
if ($_SESSION['maxday'] > 0)
{
$userid = $_SESSION['loggedinuserid'];
$query2 = "select id from items where date > $timelimit && userid = '$userid'";
$result2 = mysql_query($query2);
if (mysql_num_rows($result2) > $_SESSION['maxday'])
{
$_SESSION['submitstatus'] = "24 Hour Submission Limit Reached for your account";
header('Location: ' . $frompage . '');
exit;
}
}
if (!empty($_POST['thumburl']) || !empty($_FILES['userfile']['tmp_name']))
{
$thumburl = clean_string($_POST['thumburl']);
if (strpos($thumburl, ".jpg") === false && !empty($humburl))
{
$_SESSION['submitstatus'] = "Thumbnail must be in JPG format to be accepted.";
header('Location: ' . $frompage . '');
exit;
}
else
{
$alphanum = "APBHCPDEFGHIJKLILNKMDRNOPPERQRSTUVWXYZ123456789";
$rand = substr(str_shuffle($alphanum), 0, 3);
$imagedirectory = "./content/images/";
if ($auto_chmod == 1) chmod("$imagedirectory", 0777);
if (!empty($_FILES['userfile']['tmp_name']))
{
$uploadFile = $imagedirectory . $_FILES['userfile']['name'];
$name2 = $_FILES['userfile']['name'];
$ext = ereg_replace("^.+\\.([^.]+)$", "\\1", $name2);
if ($ext != "jpg")
{
$_SESSION['submitstatus'] = "Thumbnail must be in JPG format to be accepted. $ext";
header('Location: ' . $frompage . '');
exit;
}
if (file_exists($uploadFile))
{
$name2 = $rand . '_' . $name2;
$uploadFile = $imagedirectory . $name2;
}
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile);
}
else
{
$name2 = $thumburl;
while (strstr($name2, "/"))
{
$name2 = substr($name2, strpos($name2, "/") + 1, 999);
}
$newname2 = $imagedirectory . $name2;
if (file_exists($newname2))
{
$name2 = $rand . '_' . $name2;
$newname2 = $imagedirectory . $name2;
}
$ch = curl_init($thumburl);
$fp = fopen($newname2, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
if (filesize($newname2) < 10)
{
$_SESSION['submitstatus'] = "Unable to grab thumbnail. Please try a different file.";
header('Location: ' . $frompage . '');
exit;
}
}
$size = getimagesize($imagedirectory . $name2);
$height = $size[100];
$width = $size[100];
if ($max_thumb_height > 0 && $height > $max_thumb_height)
{
$thumbheight = $max_thumb_height;
$percent = ($height / $thumbheight);
$thumbwidth = ($width / $percent);
if ($max_thumb_width > 0 && $thumbwidth > $max_thumb_width)
{
$thumbwidthold = $thumbwidth;
$thumbwidth = $max_thumb_width;
$percent = ($thumbwidthold / $thumbwidth);
$thumbheight = ($thumbheight / $percent);
}
}
elseif ($max_thumb_width > 0 && $width > $max_thumb_width)
{
$thumbwidth = $max_thumb_width;
$percent = ($width / $thumbwidth);
$thumbheight = ($height / $percent);
if ($max_thumb_height > 0 && $thumbheight > $max_thumb_height)
{
$thumbheightold = $thumbheight;
$thumbheight = $max_thumb_height;
$percent = ($thumbheightold / $thumbheight);
$thumbwidth = ($thumbwidth / $percent);
}
}
if (!empty($thumbheight) && !empty($thumbwidth)) resize($imagedirectory . $name2, $width, $height, $thumbwidth, $thumbheight);
if ($auto_chmod == 1) chmod("$imagedirectory", 0755);
}
}
if ($_SESSION['preapproved'] == 1) $submitstatus = 1;
elseif ($_SESSION['approval'] == 1) $submitstatus = 1;
elseif ($submissions == 0 && empty($submitstatus)) $submitstatus = 3;
else $submitstatus = 1;
$userid = $_SESSION['loggedinuserid'];
$insert_content = mysql_query("INSERT into items set title = '$contenttitle', description = '$contentdescription', date = '$now', url = '$contenturl', category = '$category', image = '$name2', ipaddress = '$ipaddress', userid = '$userid', status = '$submitstatus'");
$_SESSION['submission'] = $now;
if ($submissions == 1) $_SESSION['submitstatus'] = "Link Added! Thank You!";
else $_SESSION['submitstatus'] = "Submission received. Will be posted once confirmed!";
header('Location: ' . $frompage . '');
exit;
}
elseif ($action == "submititem" && ($member_submit == 0 || ($member_submit == 1 && $_SESSION['loggedin'] == 1)))
{
when i try to submit picture show me this error
Warning: move_uploaded_file(./content/images/SJV_Ugly longhairy dude took a shower.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/ivanco4/public_html/index.php on line 245
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpd2Fbay' to './content/images/SJV_Ugly longhairy dude took a shower.jpg' in /home/ivanco4/public_html/index.php on line 245
Warning: getimagesize(./content/images/SJV_Ugly longhairy dude took a shower.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/ivanco4/public_html/index.php on line 274
Warning: Cannot modify header information - headers already sent by (output started at /home/ivanco4/public_html/index.php:245) in /home/ivanco4/public_html/index.php on line 316
here is the script can you help me please
}
}
if ($_SESSION['maxday'] > 0)
{
$userid = $_SESSION['loggedinuserid'];
$query2 = "select id from items where date > $timelimit && userid = '$userid'";
$result2 = mysql_query($query2);
if (mysql_num_rows($result2) > $_SESSION['maxday'])
{
$_SESSION['submitstatus'] = "24 Hour Submission Limit Reached for your account";
header('Location: ' . $frompage . '');
exit;
}
}
if (!empty($_POST['thumburl']) || !empty($_FILES['userfile']['tmp_name']))
{
$thumburl = clean_string($_POST['thumburl']);
if (strpos($thumburl, ".jpg") === false && !empty($humburl))
{
$_SESSION['submitstatus'] = "Thumbnail must be in JPG format to be accepted.";
header('Location: ' . $frompage . '');
exit;
}
else
{
$alphanum = "APBHCPDEFGHIJKLILNKMDRNOPPERQRSTUVWXYZ123456789";
$rand = substr(str_shuffle($alphanum), 0, 3);
$imagedirectory = "./content/images/";
if ($auto_chmod == 1) chmod("$imagedirectory", 0777);
if (!empty($_FILES['userfile']['tmp_name']))
{
$uploadFile = $imagedirectory . $_FILES['userfile']['name'];
$name2 = $_FILES['userfile']['name'];
$ext = ereg_replace("^.+\\.([^.]+)$", "\\1", $name2);
if ($ext != "jpg")
{
$_SESSION['submitstatus'] = "Thumbnail must be in JPG format to be accepted. $ext";
header('Location: ' . $frompage . '');
exit;
}
if (file_exists($uploadFile))
{
$name2 = $rand . '_' . $name2;
$uploadFile = $imagedirectory . $name2;
}
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile);
}
else
{
$name2 = $thumburl;
while (strstr($name2, "/"))
{
$name2 = substr($name2, strpos($name2, "/") + 1, 999);
}
$newname2 = $imagedirectory . $name2;
if (file_exists($newname2))
{
$name2 = $rand . '_' . $name2;
$newname2 = $imagedirectory . $name2;
}
$ch = curl_init($thumburl);
$fp = fopen($newname2, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
if (filesize($newname2) < 10)
{
$_SESSION['submitstatus'] = "Unable to grab thumbnail. Please try a different file.";
header('Location: ' . $frompage . '');
exit;
}
}
$size = getimagesize($imagedirectory . $name2);
$height = $size[100];
$width = $size[100];
if ($max_thumb_height > 0 && $height > $max_thumb_height)
{
$thumbheight = $max_thumb_height;
$percent = ($height / $thumbheight);
$thumbwidth = ($width / $percent);
if ($max_thumb_width > 0 && $thumbwidth > $max_thumb_width)
{
$thumbwidthold = $thumbwidth;
$thumbwidth = $max_thumb_width;
$percent = ($thumbwidthold / $thumbwidth);
$thumbheight = ($thumbheight / $percent);
}
}
elseif ($max_thumb_width > 0 && $width > $max_thumb_width)
{
$thumbwidth = $max_thumb_width;
$percent = ($width / $thumbwidth);
$thumbheight = ($height / $percent);
if ($max_thumb_height > 0 && $thumbheight > $max_thumb_height)
{
$thumbheightold = $thumbheight;
$thumbheight = $max_thumb_height;
$percent = ($thumbheightold / $thumbheight);
$thumbwidth = ($thumbwidth / $percent);
}
}
if (!empty($thumbheight) && !empty($thumbwidth)) resize($imagedirectory . $name2, $width, $height, $thumbwidth, $thumbheight);
if ($auto_chmod == 1) chmod("$imagedirectory", 0755);
}
}
if ($_SESSION['preapproved'] == 1) $submitstatus = 1;
elseif ($_SESSION['approval'] == 1) $submitstatus = 1;
elseif ($submissions == 0 && empty($submitstatus)) $submitstatus = 3;
else $submitstatus = 1;
$userid = $_SESSION['loggedinuserid'];
$insert_content = mysql_query("INSERT into items set title = '$contenttitle', description = '$contentdescription', date = '$now', url = '$contenturl', category = '$category', image = '$name2', ipaddress = '$ipaddress', userid = '$userid', status = '$submitstatus'");
$_SESSION['submission'] = $now;
if ($submissions == 1) $_SESSION['submitstatus'] = "Link Added! Thank You!";
else $_SESSION['submitstatus'] = "Submission received. Will be posted once confirmed!";
header('Location: ' . $frompage . '');
exit;
}
elseif ($action == "submititem" && ($member_submit == 0 || ($member_submit == 1 && $_SESSION['loggedin'] == 1)))
{