power php,power.php

include __DIR__ . '/db/db.php';

include __DIR__ . '/func/functions.php';

$args = filter_input_array(INPUT_GET, [

'do' => FILTER_DEFAULT,

'id' => FILTER_DEFAULT

]);

if ($args == null) {

$users = Power::find('all', [

's_id' => $_SESSION['id']

]);

$result = [];

foreach ($users as $value) {

$result[] = [

'id' => $value->id,

'username' => $value->user->username,

'object' => $value->object->name,

'rw' => $value->rw,

'au' => $value->au

];

}

$temple = __DIR__ . '/module/power.phtml';

include __DIR__ . '/module/public/layout.phtml';

} else {

if ($args['do'] == 'delete') {

$record = Power::find_by_id($args['id']);

$queue[0] = [

'id' => $record->id,

's_id' => $record->r_id,

'object_id' => $record->object_id

];

$pow = [];

while ($queue != null) {

$font = array_pop($queue);

$record = Power::find('all', [

's_id' => $font['s_id'],

'object_id' => $font['object_id'],

]);

foreach ($record as $re) {

$value = [

'id' => $re->id,

's_id' => $re->r_id,

'object_id' => $re->object_id

];

$choose = Power::find('all', [

'r_id' => $re->s_id,

'object_id' => $re->object_id

]);

if ($choose != null) {

if ($choose == null) {

array_push($queue, $value);

} else {

array_push($pow, $record);

}

}

}

Power::delete_all([

'conditions' => [

'id' => $font['id']

]

]);

jumpTo('delete OK', 'power.php');

}

while ($pow != null) {

$res = 0;

$font = array_pop($pow);

$power = Power::find('all', [

'r_id' => $font[0]->s_id,

'object_id' => $font[0]->object_id

]);

foreach ($power as $value) {

if ($res == 0) {

$res = $value->rw;

} else if ($res != $value->rw) {

$res = 3;

}

}

$update = Power::find('all', [

's_id' => $font[0]->s_id,

'object_id' => $font[0]->object_id

]);

foreach ($update as $value) {

$value->update_attributes([

'rw' => $res

]);

}

}

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值