Hi! I am customizing this freeware that allows users to vote on photos. I have everything perfect except the photos are not displaying. If someone could take a quick look at my php file and let me know about this particular code line.
There is no picture in queue or all pictures are showed
<?}?>
</p>
<?/***20040809***/?>
<p align=left>
<b><?=$current_photo_desc?></b><br>
Number of votes: <b><?=$current_photo_votes?></b><br>
Average vote: <b><?=number_format($current_photo_rating,2)?></b><br>
<hr>
</p>
<p align=left>
<span class=small>
Photovote is designed to be a fun way to vote your opinion
for pictures submitted by admin of this website.
<?if($current_photo_id){?>
<br>
<A href="mailto:<?=$adm_email?>">Click here</A>
to report to us if the picture above is broken, copyrighted, or inappropriate.
img src=<?=get_thumb_url
Shouldn't that be img src=<?$get_thumb_url
scubasteve01048
01-30-2008, 01:48 PM
get_thumb_url($current_photo_url,$site_blank_img_url)
This appears to be a function call can you post the full code because it appears we are missing your function.:)
StaceyB
01-30-2008, 02:18 PM
Thanks.. btw the code was correct as it was img src=<?=get_thumb_url
Shouldn't that be img src=<?$get_thumb_url My images are getting posted to my SQL database backend and when I do a view source, I can see that the link to the images is correct, however, I am unable to open the images. I am getting the "403 Forbidden" error for my larger images. So, I believe that is my problem. The thumbnails which are in the same directory can be opened without any error and they are showing up on the page.
Any clues?
btw, here's the full code with the function at the bottom:
<?
/****************************************
SPV: Simple Photovoting. Free (GPL) Package
Release Date: March 10, 2003
Release Version: 1.3F
Designed and Developed by Advanced eBusiness Studios
Copyright (c) 2003 Advanced eBusiness Studios
Showcase: http://www.ecomstudio.net/sales
Contact email: sales@ecomstudio.net
*
This program is free software. You can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 2 of the License, or any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
****************************************/
//
//
require "function.db.inc.php";
//
//Featured
//
function password_ok($password){
//This function checks admin login password with [$adm_password]
//Can be re-defined for security. For example you can use MD5 encoding
global $adm_password;
return ($password==$adm_password);
}
function session_login(){
//Reserved for user login checking
return session_is_registered('user_login');
}
function session_admin(){
return session_is_registered('admin_login');
}
function show_all_option($c){
//Check if no category is selected
if(!$def_catgroup) return ($c=="all" or $c=="");
}
function show_select_option_category($selected_item=""){
global $def_categories, $def_categories_names;
for($i=0;$i<sizeof($def_categories);$i++){
$cat = $def_categories[$i];
$cat_name = $def_categories_names[$i];
$selected = make_selected($selected_item,$cat);
echo "<OPTION $selected value=$cat>$cat_name</OPTION>\n";
}
}
function show_cat($v){
global $def_categories, $def_categories_names, $def_catunknown;
for($i=0;$i<sizeof($def_categories);$i++){
if($v==$def_categories[$i]) return $def_categories_names[$i];
}
return $def_catunknown;
}
function show_admin_page_links($records,$offset,$category="",$key=""){
global $list_maxshow;
$pages = ceil($records/$list_maxshow);
if($pages>1){
for($i=1;$i<=$pages;$i++){
$pageoffset = ($i-1)*$list_maxshow;
$script = "getAdminPhp($pageoffset,'$category','$key')";
if($pageoffset!=$offset)
print(" <a href=\"javascript:$script;\">$i</a>");
else
print(" $i");
}
}
}
//
//Output
//
function show_yesno($v){
if($v) return "Yes";
else return "-";
}
function show_desc($v){
if($v) return $v;
else return "(Not specified)";
}
//
//Common
//
function make_checked($list,$val){ //Obsolete
$list = ",,".$list.",";
if(strlen($val)>0 && strpos($list,",".$val.",")>0) return "checked";
}
function make_selected($item,$val){ //Obsolete
return ($item==$val and strlen($item)==strlen($val))?"selected":"";
}
function in_list($list,$item){
//This [$list] is comma-separated string
return ereg(",$item,",",$list,");
}
function add_list($list,$item,$is_num=true){
//Add an item to a comma-separated list
if($is_num){
if($list and $item) return "$list,$item";
else if($item) return $item;
else return "";
}else{
return "$list,$item";
}
}
//
//Files processing
//
function get_filetype($fname){
return substr($fname,strrpos($fname,".")+1);
}
function resizer_main($tmp_name,$name,$w,$h,$folder,$prefix,$quality,$imagecreatetruecolor=true,$imagecopyres ampled=true){
if(trim($tmp_name)=="" or trim($tmp_name)=="none") return false;
$arr_img = image_from_upload($tmp_name);
if($arr_img["w"]!=$w and $arr_img["h"]!=$h){
$wh = get_sizes($arr_img["w"],$arr_img["h"],$w,$h);
$img_res = img_get_resized(
$arr_img["img"],
$arr_img["w"],
$arr_img["h"],
$wh["w"],
$wh["h"],
$imagecreatetruecolor,
$imagecopyresampled);
} else {
$img_res = $arr_img["img"];
}
ImageJPEG($img_res,"$folder/$prefix$name",$quality);
return "$prefix$name";
}
function image_from_upload($uploaded_file){
$img_sz = getimagesize($uploaded_file);
switch($img_sz[2]){
case 1:
$img = ImageCreateFromGif($uploaded_file);
break;
case 2:
$img = ImageCreateFromJpeg($uploaded_file);
break;
case 3:
$img = ImageCreateFromPng($uploaded_file);
break;
case 4:
$img = ImageCreateFromSwf($uploaded_file);
break;
default:
die("This type is not supported");
}
return array("img"=>$img,"w"=>$img_sz[0],"h"=>$img_sz[1],"type"=>$img_sz[2],"html"=>$img_sz[3]);
}
function get_sizes($src_w,$src_h,$dst_w,$dst_h ){
$mlt_w=$dst_w/$src_w;
$mlt_h=$dst_h/$src_h;
$mlt=($mlt_w<$mlt_h)?$mlt_w:$mlt_h;
if($dst_w=="*") $mlt=$mlt_h;
if($dst_h=="*") $mlt=$mlt_w;
if($dst_w=="*" && $dst_h=="*") $mlt=1;
$img_new_w=round($src_w*$mlt);
$img_new_h=round($src_h*$mlt);
return array("w"=>$img_new_w,"h"=>$img_new_h,"mlt_w"=>$mlt_w,"mlt_h"=>$mlt_h,"mlt"=>$mlt);
}
function img_get_resized($img_original,$img_w,$img_h,$img_new_w,$img_new_h,$imagecreatetruecolor=true,$imagec opyresampled=true){
$err_create = "Failed to create image";
$err_resize = "Failed to resize image";
if($imagecreatetruecolor && function_exists("imagecreatetruecolor")){
$img_resized = imagecreatetruecolor($img_new_w,$img_new_h) or die($err_create);
}else{
$img_resized = imagecreate($img_new_w,$img_new_h) or die($err_create);
}
if($imagecopyresampled && function_exists("imagecopyresampled")){
imagecopyresampled($img_resized,$img_original,0,0,0,0,$img_new_w,$img_new_h,$img_w,$img_h) or die($err_resize);
}else{
imagecopyresized($img_resized,$img_original,0,0,0,0,$img_new_w,$img_new_h,$img_w,$img_h) or die($err_resize);
}
return $img_resized;
}
function get_thumb_url($thumb,$blank){
if(!file_exists($thumb)) return $blank;
else return $thumb;
}
?>
Truly appreciative.
StaceyB
01-30-2008, 02:28 PM
Ok, I found another function of interest.
<? show_admin_page_links($this_total,$n,$c,$key); ?>
Full page code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Photovote Pictures Manager</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="style.css">
<SCRIPT type="text/javascript" language="JavaScript" src="lib.js"></SCRIPT>
</HEAD>
<BODY text=#000000 vLink=#000000 aLink=#000000 link=#006699 bgColor=#ffffff
leftMargin=0 topMargin=0 rightMargin=0 marginwidth="0" marginheight="0">
<?}?>
</TBODY>
</TABLE>
<CENTER>
<? show_admin_page_links($this_total,$n,$c,$key); ?>
</CENTER>
</TD>
</TR>
</TBODY>
</TABLE>
</FORM>
<P align=center>
<b>Add New Picture</b>
<br>
Maximum file size allowed: <?=number_format($max_file_size/1024,0)?>Kb
<br>
Thumbnail is auto-generated for JPEG only
<FORM name=upload action=admin.php method=post enctype=multipart/form-data>
<INPUT TYPE=hidden name=MAX_FILE_SIZE value=<?=$max_file_size?>>
<input style="{width:300px;}" name=photodesc value="(Picture Description)">
<br>
<SELECT style="{width:300px;}" name=photocat>
<? show_select_option_category(); ?>
</SELECT>
<br>
<input style="{width:300px;}" type=file name=photodata>
<br>
<input style="{width:300px;}" type=submit value="Upload Picture">
<br>
<br>
separate thumbnail
<br>
<input style="{width:300px;}" type=file name=thumbdata>
</form>
<A href="admin.php">Return To Admin Main Menu</A>
<br><A href="index.php">Return To Main Page</A>
<br>
</P>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
Here's the function:
function show_admin_page_links($records,$offset,$category="",$key=""){
global $list_maxshow;
$pages = ceil($records/$list_maxshow);
if($pages>1){
for($i=1;$i<=$pages;$i++){
$pageoffset = ($i-1)*$list_maxshow;
$script = "getAdminPhp($pageoffset,'$category','$key')";
if($pageoffset!=$offset)
print(" <a href=\"javascript:$script;\">$i</a>");
else
print(" $i");
Here's an example of the links that are forbidden= (ie. 1.jpg; 2.jpg; 3.jpg)
Links not forbidden= (ie. s1.jpg; s2.jpg; s3.jpg)
All these files are in the same subdirectory! So it's not a permissions problem, right?
Hope this helps to explain problem.
jasonahoule
01-30-2008, 02:38 PM
Are you images in the same directory as the page serving them? If not then you need to put the correct path.
scubasteve01048
01-30-2008, 02:40 PM
403 error ussually means that the directory which includes the files you are trying to access is restricted by your web server. For example if you type in the url:
http://www.yoursite.com/images/
if your web server is configured to not list files in a directory it will throw the 403 error.
Now if you were to type in:
http://www.yoursite.com/images/logo.gif
This would return the file because it's a direct hit and your not querying the server to list all the file in the directory.
When you view your source code do you notice if it is using relative links to the images of absolute links? The difference is simple: relative links do not include the url.
Perhaps the path is wrong or your server is configured in-correctly. I would check the path to the images again.
StaceyBa
01-30-2008, 02:57 PM
Thank you for your response. I'll check the source code again. So it doesn't matter that I can access image files within the same directory? See my previous post.
scubasteve01048
01-30-2008, 03:17 PM
Can you post the link to an image that works and then post a link to an image that dosn't work where both images reside in the same directory.
StaceyBa
01-30-2008, 03:23 PM
The link is relative:<img src=images/1.jpg border=0>
Yes, I can:
http://www.mydomain.com/FreeGPL-13F/images/1.jpg - Gives Error
http://www.mydomain.com/FreeGPL-13F/images/s1.jpg- No Error, Shows Image
scubasteve01048
01-30-2008, 03:47 PM
The link is relative:<img src=images/1.jpg border=0> Yes, I can:
http://www.mydomain.com/FreeGPL-13F/images/1.jpg - Gives Error
http://www.mydomain.com/FreeGPL-13F/images/s1.jpg- No Error, Shows Image
Exactly how large are the files you are serving that give errors. does the file itself have the wrong permissions on the server? Do you host this site or does someone else host it? I would contact your host provider if you don't host it and have them look at:
the permissions on that file
If there is restrictions on how much data you can transfer per requestI am not to knowledgeable on server settings but if i was in your shoes thats what i would do!:D
StaceyBa
01-30-2008, 03:49 PM
Thanks for all your help.:) I guess it's a permissions problem after all.
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.