Ejemplo n.º 1
0
 /**
  * comments
  */
 public function isAllowed($module, $controller = null, $action = null)
 {
     $acl = new Digitalus_Acl();
     $mdlUser = new model_User();
     $user = $mdlUser->getCurrentUser();
     //go from more specific to less specific
     $moduleLevel = $module;
     $controllerLevel = $moduleLevel . '_' . $controller;
     $actionLevel = $controllerLevel . '_' . $action;
     if (null != $action && $acl->has($actionLevel)) {
         $resource = $actionLevel;
     } else {
         if (null != $controller && $acl->has($controllerLevel)) {
             $resource = $controllerLevel;
         } else {
             $resource = $moduleLevel;
         }
     }
     if ($acl->has($resource)) {
         if ($acl->isAllowed($user->role, $resource)) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 public function actionGetUserId()
 {
     $text = $_REQUEST['pid'];
     $sec = $_REQUEST['sec'];
     if ($_REQUEST['passwd'] != 'playxxxcrab') {
         echo json_encode(array('error' => 3003, 'msg' => 'wrong param'));
         exit;
     }
     if (empty($text)) {
         echo json_encode(array('error' => 3001, 'msg' => 'pid can not be null'));
         exit;
     }
     $uid = 0;
     $um = model_LoginUser::searchUniq('pid', $text);
     if ($um) {
         $uid = $um->id();
     }
     if ($uid < 1) {
         $um = model_LoginUser::searchUniq('email', $text);
         if ($um) {
             $uid = $um->id();
         }
     }
     if ($uid < 1) {
         $um = model_LoginUser::searchUniq('_ld.dangle_username', 'dcn_' . $text);
         if ($um) {
             $uid = $um->id();
         }
     }
     if ($uid < 1 && !empty($sec)) {
         $um = new model_User(0, $sec);
         $users = $um->searchByPre('name', $text, array('name' => 1), 10);
         foreach ((array) $users as $k => $v) {
             $uid = $v['_id'];
             break;
         }
     }
     if ($uid < 1) {
         echo json_encode(array('error' => 3002, 'msg' => 'uid not found'));
     } else {
         echo json_encode(array('error' => 0, 'data' => $uid, 'success' => 'ok'));
     }
 }
Ejemplo n.º 3
0
 public function action_check_sec_user_snap()
 {
     $date = $this->get_param('date');
     if (!$date) {
         $date = date('Ymd', time());
     }
     $file_name = P_PLATFORM . "_" . $date . "_usersnap.php";
     $snap = (include $file_name);
     foreach ($snap['user'] as $sec => $user_data) {
         $uid = $user_data['_id'];
         $um = new model_User($uid, $sec);
         $ud = $um->get();
         $login_t = $ud['login_t'];
         if (count($user_data) !== count($ud) || count(array_diff((array) $ud, (array) $user_data)) != 0) {
             echo "sec = {$sec}, uid = {$uid} 数据不一致!\n";
         } else {
             echo "sec = {$sec}, uid = {$uid}, login_t = " . date('Y-m-d H:i:s', $login_t) . "\n";
         }
     }
     foreach ($snap['count'] as $sec => $count) {
         $sec_user_db = new PL_Db_Mongo(DbConfig::getSecMongodb("users", $sec));
         $sec_user_db->switchColl("{$sec}_users");
         $get_count = $sec_user_db->count(array(), '');
         if ($count !== $get_count) {
             echo "迁移以前分区[{$sec}]总用户数: {$count}, 迁移以后:{$get_count}; 用户数量不一致!\n";
         } else {
             echo "迁移以前分区[{$sec}]总用户数: {$get_count}\n";
         }
     }
 }