dongzhouji4021 2013-01-30 19:00
浏览 31

用户私有图片,设置用户权限'0'或'1'?

I am trying to create a basic user permissions system. users can upload photos into their private section and if one user wants to view these they request permission to the other user.

The bit i am working on at the moment is allowing the user to see that other users photos depending on their enum value being set either to '0' or '1' in the column 'privilege' within my database 'ptb_permissions'.

I am using a mysql table with three columns like so:

user_id    |   private_id   |  privilege 

   1                4               1
   2                6               0

I want it to be user specific so if user one requests to see user 4's photos and user 1 says this is ok, they set user 4's privelege from '0' to '1'.

so if the user tries to view a private photo and they are not permitted to this will show a template image of a padlock which indicates tehy are not allowed to see this photo.

If they are allowed to see this photo then the photo will change from being a padlock image to the actual image.

Heres the code that i have so far, however it is bringing an error up saying called to undefined function.

can someone please show me how i can get this to work.

thank you.

i hope i have explained this well enough please ask if you need more information.

function:

function account_perms() {
            global $connection;
            global $_SESSION;
            global $profile_id;
            $query = "SELECT *
                        FROM ptb_permissions
                        WHERE ptb_permissions.private_id = \"$profile_id\"
                        AND ptb_permissions.user_id = ".$_SESSION['user_id']." ";
            $account_perms = mysql_query($query, $connection);
            confirm_query($query, $connection);
            return $account_perms;
        }

code:

<?php
        $account_perms = account_perms();

        while ($perms = mysql_fetch_array($account_perms)) {
             if ($perms['privelege'] = '1')  {


            ?>


<?php            
$photo = "data/private_photos/$profile[1]/pic1.jpg";

$thumb = "data/private_photos/$profile[1]/thumb_pic1.jpg";

echo
"<li><a href=\"$photo\" rel=\"shadowbox\" title=\"<strong>$profile[2]'s Photo's</strong>\"><img src=\"$thumb\" width=\"90\" height=\"90\" alt=\"<strong>{$profile[2]}'s Photos</strong>\"  /></a></li>";
    }
        }

else 

$photo = "data/other/other/_default.jpg";

$thumb = "data/other/other/_default.jpg";

echo
"<li><a href=\"$photo\" rel=\"shadowbox\" title=\"<strong>$profile[2]'s Photo's</strong>\"><img src=\"$thumb\" width=\"90\" height=\"90\" alt=\"<strong>{$profile[2]}'s Photos</strong>\"  /></a></li>";
    }
        }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度