示例#1
0
 function goModify()
 {
     $power = new Power(&$this->dbObj, $this->getUid());
     $p = $_POST['updid'] + 0;
     $sql = "SELECT otherruleid,configdefault FROM " . WEB_ADMIN_TABPOX . "otherrule WHERE (isrule = 0) AND (issystemvar = 0) AND (ruleid = {$p})";
     $rs = $this->dbObj->GetArray($sql);
     foreach ($rs as $v) {
         $power->parseSqlData(&$v);
         $def = explode('#', $v['configdefault']);
         sort($def);
         $def = implode('#', $def);
         $posData =& $_POST['attachs'][$p];
         if (array_key_exists($v['otherruleid'], $posData)) {
             $tposd = $posData[$v['otherruleid']];
             if (is_array($tposd)) {
                 sort($tposd);
                 $val = implode('#', $tposd);
             } else {
                 $val = $tposd;
             }
             $this->dbObj->Execute('DELETE FROM ' . WEB_ADMIN_TABPOX . 'config WHERE (userid = ' . $this->getUid() . ') AND (otherruleid = ' . $v['otherruleid'] . ')');
             if ($def != $val) {
                 $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . 'config(userid,otherruleid,configvalue,importer)VALUES(' . $this->getUid() . ',' . $v['otherruleid'] . ",'" . $val . "'," . $this->getUid() . ')');
             }
         }
     }
     exit('<script>alert("设置成功!");history.go(-1);</script>');
 }
示例#2
0
文件: top.php 项目: TonyWoo/cmlerp
 function goDelete()
 {
     $delid = $_GET[DELETE . 'id'] + 0;
     require_once WEB_ADMIN_CLASS_PATH . '/power/Power.cls.php';
     $powerObj = new Power(&$this->dbObj, $this->getUid());
     $powerObj->delUser($delid);
     $this->quit('删除成功!');
 }
示例#3
0
 public function __construct($node, $parent)
 {
     parent::__construct($node, $parent);
     self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes);
     self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes);
     self::$possible_children = array_merge(parent::$possible_children, self::$possible_children);
     self::$required_children = array_merge(parent::$required_children, self::$required_children);
 }
示例#4
0
 private static function initializeConnection()
 {
     if (is_null(self::$dbConn)) {
         self::$dbConn = DatabasePDO::getInstance();
     }
 }
示例#5
0
    <link rel="stylesheet" href="css.css">
    <link rel="stylesheet" href="rotate.css">

</head>

<body class="bg2">
    <?php 
require "server/DatabasePDO.php";
require "server/Superhero.php";
require "server/Power.php";
$current = Superhero::findById($_POST["current"]);
$opponent = Superhero::findById($_POST["opponent"]);
$cpower = Power::findById($current->getPowerId());
$opower = Power::findById($opponent->getPowerId());
$avgcpower = Power::findAvg($current->getPowerId());
$avgopower = Power::findAvg($opponent->getPowerId());
$avgcpower = doubleval($avgcpower[0]);
$avgopower = doubleval($avgopower[0]);
?>
    <img id="upper_left" class="back_pic" src="images/batman.png" width="490px">

    <div class="container result">
        <div class="row text-center header">
            <div id="logo"></div>
        </div>

        <!--Character Start-->
        <div class="panel panel-warning ">
            <div class="panel-heading text-center">
                <h4>VERSUS</h4>
            </div>
示例#6
0
文件: role.php 项目: TonyWoo/cmlerp
 function goAppend()
 {
     $p = new Power(&$this->dbObj, $this->getUid());
     $id = 0;
     $info = '';
     if ($this->isModify) {
         $info = '修改';
         $id = $_POST[MODIFY . 'id'] + 0;
         $this->dbObj->Execute('update ' . WEB_ADMIN_TABPOX . "role set rolename='" . $_POST['rolename'] . "' where roleid = " . $id);
         $this->dbObj->Execute('delete from ' . WEB_ADMIN_TABPOX . 'rolerule where roleid = ' . $id);
         $this->dbObj->Execute('delete from ' . WEB_ADMIN_TABPOX . 'grouprole where roleid = ' . $id);
         $this->dbObj->Execute('delete from ' . WEB_ADMIN_TABPOX . 'attachrule where userorgrouporrole = 3 and userorgrouporroleid = ' . $id);
     } else {
         $info = '增加';
         $this->dbObj->Execute('insert into ' . WEB_ADMIN_TABPOX . "role(rolename,importer)values('" . $_POST['rolename'] . "'," . $this->getUid() . ")");
         $id = $this->dbObj->Insert_ID();
     }
     //角色权
     if (isset($_POST['rules'])) {
         foreach ($_POST['rules'] as $k => $v) {
             $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . 'rolerule(roleid,ruleid,issuperuser,canbrowse,canappend,canmodify,candelete,canimport, canexport, canrecoil, canaudit ,importer)' . "VALUES({$id},{$k}.," . (array_key_exists('S', $v) ? 1 : 0) . ',' . (array_key_exists('B', $v) ? 1 : 0) . ',' . (array_key_exists('A', $v) ? 1 : 0) . ',' . (array_key_exists('M', $v) ? 1 : 0) . ',' . (array_key_exists('D', $v) ? 1 : 0) . ',' . (array_key_exists('I', $v) ? 1 : 0) . ',' . (array_key_exists('E', $v) ? 1 : 0) . ',' . (array_key_exists('R', $v) ? 1 : 0) . ',' . (array_key_exists('H', $v) ? 1 : 0) . ',' . $this->getUid() . ')');
         }
     }
     //附加权
     if (isset($_POST['attachs'])) {
         foreach ($_POST['attachs'] as $k => $v) {
             foreach ($v as $ink => $inv) {
                 $currentStr = $inv;
                 if (is_array($inv)) {
                     sort($inv);
                     reset($inv);
                     $currentStr = implode('#', $inv);
                 }
                 $df = $this->dbObj->GetRow('select configdefault from ' . WEB_ADMIN_TABPOX . 'otherrule where otherruleid = ' . $ink);
                 $p->parseSqlData(&$df);
                 //默认值
                 $sourceStr = explode('#', $df['configdefault']);
                 sort($sourceStr);
                 $sourceStr = implode('#', $sourceStr);
                 if ($sourceStr != $currentStr) {
                     $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . 'attachrule(userorgrouporrole,userorgrouporroleid,addordel,ruleid,otherruleid,configvalue,importer)' . "values(3,{$id},1,{$k},{$ink},'{$currentStr}'," . $this->getUid() . ')');
                 }
             }
         }
     }
     //所在组
     if (isset($_POST['groups'])) {
         foreach ($_POST['groups'] as $v) {
             $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . "grouprole(groupid,roleid,importer)VALUES({$v},{$id}," . $this->getUid() . ')');
         }
     }
     if ($this->isModify) {
         $this->dbObj->Execute("update " . WEB_ADMIN_TABPOX . "login set updatestate = 1 where userid in(\r\n\t\t\t\tselect ug.userid from " . WEB_ADMIN_TABPOX . "usergroup ug \r\n\t\t\t\tinner join " . WEB_ADMIN_TABPOX . "grouprole gr on ug.groupid = gr.groupid where gr.roleid = {$id})");
     }
     $this->quit($info . '完成!');
 }
示例#7
0
 /**
 @desc 删除一个菜单
 */
 function delMenuItem($mid)
 {
     require_once WEB_ADMIN_CLASS_PATH . '/power/Power.cls.php';
     $p = new Power(&$this->_db, null);
     $rs = $this->getMenuItemToArray2($mid);
     $rs[count($rs)]['ruleid'] = $mid;
     foreach ($rs as $v) {
         $imgfiles = $this->_db->GetRow('SELECT ruleimg,rulebigimg FROM ' . WEB_ADMIN_TABPOX . 'rule WHERE ruleid = ' . $v['ruleid']);
         if ($imgfiles['ruleimg']) {
             unlink(WEB_ADMIN_PHPCOMMON . '/img/ico/' . $imgfiles['ruleimg']);
         }
         if ($imgfiles['rulebigimg']) {
             unlink(WEB_ADMIN_PHPCOMMON . '/img/ico/' . $imgfiles['rulebigimg']);
         }
         $p->delRule($v['ruleid']);
     }
 }
示例#8
0
    <!-- Optional theme -->
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap-theme.min.css">

    <!-- Latest compiled and minified JavaScript -->
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="server.js" type="text/javascript"></script>
</head>

<body class="bg2">
    <?php 
require "server/DatabasePDO.php";
require "server/Power.php";
require "server/Superhero.php";
$powers = Power::findAllAvg();
?>
    <img id="upper_right" class="reflect back-panel" src="images/ironman.png" width="500px">

    <div class="container result">
        <div class="row text-center header">
            <div class="row">
                <div id="logo"></div>
            </div>
            <br>
            <br>
        </div>

        <!--Character Start-->
        <div class="panel panel-default">
            <div class="panel-heading text-center">
示例#9
0
    function disp()
    {
        $powerObj = new Power(&$this->dbObj, $this->getUid());
        $t = new Template('../template/user');
        $t->set_file('f', 'userconfig.html');
        $t->set_block('f', 'row', 'r');
        $t->set_block('f', 'rule', 'ru');
        if ($this->getModify()) {
            $t->set_var('form', '<form name="form1" method="post" action="userconfig.php">');
            $t->set_var('endform', '</form>');
        } else {
            $t->set_var('disabled', ' disabled');
        }
        //得到所有附加权
        $attachArr = array();
        $sql = '
			select c.configvalue as userdefalue,r.rulename,o.* from ' . WEB_ADMIN_TABPOX . 'otherrule o 
				LEFT OUTER JOIN ' . WEB_ADMIN_TABPOX . 'rule r ON o.ruleid = r.ruleid 
				LEFT OUTER JOIN ' . WEB_ADMIN_TABPOX . 'config c ON o.otherruleid = c.otherruleid AND c.userid = ' . $this->getUid() . '
			where o.isrule = 1
		';
        $attachRs = $this->dbObj->Execute($sql);
        while ($tmpRrs = $attachRs->FetchRow()) {
            $powerObj->parseSqlData(&$tmpRrs);
            $attachArr[$tmpRrs['ruleid']][$tmpRrs['configvarname']] = $tmpRrs;
        }
        $attachRs->Close();
        //得到用户的权限
        $userRule = $powerObj->getUserRule($this->getUid());
        $have = 'none';
        foreach ($userRule['attach'] as $k => $v) {
            //附加权,菜单
            foreach ($v as $ink => $inv) {
                //附加权,菜单下的权
                if (is_array($inv) && count($inv) > 1 && $attachArr[$k][$ink]['configtype'] != 'checkbox') {
                    $t->set_var('rulename', $attachArr[$k][$ink]['rulename']);
                    $t->set_var('configname', $attachArr[$k][$ink]['configname']);
                    $values = '';
                    $default = explode('#', $attachArr[$k][$ink]['configvalue']);
                    foreach ($inv as $in_v) {
                        //权限下的每一项
                        foreach ($default as $inn_v) {
                            //权限的默认值
                            $vs = split('=', $inn_v);
                            if (!isset($vs[1])) {
                                $vs[1] = $vs[0];
                            }
                            $checked = '';
                            if ($vs[1] == $in_v) {
                                if ($attachArr[$k][$ink]['userdefalue'] == $in_v) {
                                    $checked = ' checked';
                                }
                                $values .= '<input type="radio" name="attachrule[' . $attachArr[$k][$ink]['otherruleid'] . ']" value="' . $vs[1] . '"' . $checked . '>' . $vs[0] . ' ';
                            }
                        }
                    }
                    $t->set_var('values', $values);
                    $t->parse('ru', 'rule', true);
                    $have = '';
                }
            }
        }
        $t->set_var('dispMore', $have);
        //显示可选择项
        $dap = new DispAttachRule(&$this->dbObj, $this->getUid());
        $rs = $this->dbObj->GetArray('select * from ' . WEB_ADMIN_TABPOX . 'otherrule where (ruleid is null OR ruleid = 0) and (issystemvar = 0) and (isrule is null OR isrule = 0)');
        foreach ($rs as $v) {
            $sval = $this->dbObj->GetOne('select configvalue from ' . WEB_ADMIN_TABPOX . 'config where (userid=' . $this->getUid() . ') and (otherruleid=' . $v['otherruleid'] . ')');
            $t->set_var($dap->disp($v, $sval, "</td><td width='50%'><nobr>", 2, "</nobr></td></tr><tr><td width='25%'>"));
            $t->parse('r', 'row', true);
        }
        $t->set_var('configName', '用户');
        $t->set_var('path', WEB_ADMIN_HTTPPATH . '/common/');
        $t->parse('out', 'f');
        $t->p('out');
    }
示例#10
0
 public function groupSetHasPowerByName($groupIds, $powerName)
 {
     $power = Power::where('name', '=', $powerName)->first();
     if ($power == null) {
         throw new \Exception("Unknown power name " . $powerName);
     }
     return $this->groupSetHasPower($groupIds, $power);
 }
示例#11
0
    <script src="server.js" type="text/javascript"></script>
</head>

<body class="bg2">
    <?php 
require "server/DatabasePDO.php";
require "server/Superhero.php";
require "server/Team.php";
require "server/Power.php";
require "server/Gallery.php";
require "server/Alignment.php";
require "server/MemberOf.php";
require "server/PortraitedBy.php";
require "server/Star.php";
$superhero = Superhero::findById($_POST["superheroID"]);
$power = Power::findBySuperheroId($superhero->getId());
$alignment = Alignment::findBySuperheroId($superhero->getId());
$memberof = MemberOf::findBySuperheroId($superhero->getId());
$portraitedby = PortraitedBy::findBySuperheroId($superhero->getId());
$gallerys = Gallery::findBySuperheroId($superhero->getId());
?>
    <img id="upper_right" class="reflect ironman" src="images/ironman.png" width="450px">

    <div class="container result">
        <div class="row text-center header">
            <div id="logo"></div>
        </div>

        <!--Character Start-->
        <div class="panel panel-warning ">
            <div class="panel-heading text-center">
示例#12
0
<?php

require "DatabasePDO.php";
require "Power.php";
require "PortraitedBy.php";
$power1 = Power::findAvg(1);
$power2 = Power::findAvg(2);
var_dump(doubleval($power1[0]));
示例#13
0
<?php

/**
 * Created by PhpStorm.
 * User: admin
 * Date: 25.01.2016
 * Time: 19:12
 */
class Power
{
    public function powTo($number, $step)
    {
        $result = 1;
        for ($x = 0; $x < $step; $x++) {
            $result = $result * $number;
        }
        return $result;
    }
}
$a = new Power();
echo $a->powTo(5, 5);
echo '<br>';
echo $a->powTo(6, 6);
echo '<br>';
echo $a->powTo(7, 7);
echo '<br>';
//var_dump($_SERVER);
echo $_SERVER["REQUEST_URI"];
示例#14
0
 /**
  * 获得当前页的相关权限,值,或数组值
  */
 function getAttachRule($varname, $id = null)
 {
     require_once WEB_ADMIN_CLASS_PATH . '/power/Power.cls.php';
     $p = new Power($this->_db, $this->getUid());
     if (is_null($id)) {
         $id = $this->_pageid;
     } else {
         if (!is_numeric($id)) {
             $id = $this->getMenuId($id);
         }
     }
     $sql = "\r\n\t\t\tSELECT configtype,configdefault,c.configvalue AS userdefault FROM " . WEB_ADMIN_TABPOX . "otherrule o \r\n\t\t\t\tLEFT OUTER JOIN\t" . WEB_ADMIN_TABPOX . "config c ON ( (o.otherruleid = c.otherruleid) AND (c.userid = " . $this->getUid() . ") )\r\n\t\t\tWHERE (o.isrule = 1) AND (configvarname = '{$varname}') AND (ruleid = {$id})\r\n\t\t";
     $sourceStr = $this->_db->GetRow($sql);
     $p->parseSqlData(&$sourceStr);
     //		print_r($this->_attachRuleArray[$id]);
     //		print_r($sourceStr);
     //		echo '<br>',$varname,'<br>';
     //		echo $id,$varname;
     //		print_r($this->_attachRuleArray[$id][$varname]);
     if (isset($this->_attachRuleArray[$id][$varname])) {
         if (!is_array($this->_attachRuleArray[$id][$varname])) {
             return $this->_attachRuleArray[$id][$varname];
         } else {
             if (isset($sourceStr['configtype'])) {
                 switch (strtolower($sourceStr['configtype'])) {
                     case 'text':
                     case 'select':
                     case 'radio':
                         //有多个可选项的单选项
                         if (strlen($sourceStr['userdefault']) > 0) {
                             return $sourceStr['userdefault'];
                         } else {
                             if (in_array($sourceStr['configdefault'], $this->_attachRuleArray[$id][$varname])) {
                                 return $sourceStr['configdefault'];
                             } else {
                                 sort($this->_attachRuleArray[$id][$varname]);
                                 return $this->_attachRuleArray[$id][$varname][0];
                             }
                         }
                         break;
                     default:
                         return $this->_attachRuleArray[$id][$varname];
                         break;
                 }
             } else {
                 return false;
             }
         }
     } else {
         if (isset($sourceStr['configdefault'])) {
             if (strpos($sourceStr['configdefault'], '#')) {
                 return explode('#', $sourceStr['configdefault']);
             } else {
                 return $sourceStr['configdefault'];
             }
         } else {
             return false;
         }
     }
 }